* Fix #12410, big thanks to @pmetras for this fix

* Add testcase
This commit is contained in:
Clyybber 2020-10-23 03:26:50 +02:00 • committed by GitHub
commit 01a62320f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -242,7 +242,7 @@ proc readDataStr*(s: Stream, buffer: var string, slice: Slice[int]): int =
result = s.readDataStrImpl(s, buffer, slice) result = s.readDataStrImpl(s, buffer, slice)
else: else:
# fallback # fallback
result = s.readData(addr buffer[0], buffer.len) result = s.readData(addr buffer[slice.a], slice.b + 1 - slice.a)
template jsOrVmBlock(caseJsOrVm, caseElse: untyped): untyped = template jsOrVmBlock(caseJsOrVm, caseElse: untyped): untyped =
when nimvm: when nimvm:

View file

@ -6,6 +6,7 @@ Nice name: Arne
fs is: nil fs is: nil
threw exception threw exception
_heh_
''' '''
nimout: ''' nimout: '''
I I
@ -49,3 +50,15 @@ block tstreams3:
for line in s.lines: for line in s.lines:
echo line echo line
s.close s.close
# bug #12410
var a = newStringStream "hehohihahuhyh"
a.readDataStrImpl = nil
var buffer = "_ooo_"
doAssert a.readDataStr(buffer, 1..3) == 3
echo buffer