mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* Fix #12410, big thanks to @pmetras for this fix * Add testcase
This commit is contained in:
@@ -242,7 +242,7 @@ proc readDataStr*(s: Stream, buffer: var string, slice: Slice[int]): int =
|
||||
result = s.readDataStrImpl(s, buffer, slice)
|
||||
else:
|
||||
# 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 =
|
||||
when nimvm:
|
||||
|
||||
@@ -6,6 +6,7 @@ Nice name: Arne
|
||||
fs is: nil
|
||||
|
||||
threw exception
|
||||
_heh_
|
||||
'''
|
||||
nimout: '''
|
||||
I
|
||||
@@ -49,3 +50,15 @@ block tstreams3:
|
||||
for line in s.lines:
|
||||
echo line
|
||||
s.close
|
||||
|
||||
# bug #12410
|
||||
|
||||
var a = newStringStream "hehohihahuhyh"
|
||||
a.readDataStrImpl = nil
|
||||
|
||||
var buffer = "_ooo_"
|
||||
|
||||
doAssert a.readDataStr(buffer, 1..3) == 3
|
||||
|
||||
echo buffer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user