mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
* fixes #22148; std/memfiles.memSlices nesting now fails with memory safety capture violation * adds a test case
This commit is contained in:
@@ -326,7 +326,7 @@ proc introduceNewLocalVars(c: PTransf, n: PNode): PNode =
|
||||
return n
|
||||
of nkProcDef: # todo optimize nosideeffects?
|
||||
result = newTransNode(n)
|
||||
let x = freshVar(c, n[namePos].sym)
|
||||
let x = newSymNode(copySym(n[namePos].sym, c.idgen))
|
||||
idNodeTablePut(c.transCon.mapping, n[namePos].sym, x)
|
||||
result[namePos] = x # we have to copy proc definitions for iters
|
||||
for i in 1..<n.len:
|
||||
|
||||
15
tests/iter/t22148.nim
Normal file
15
tests/iter/t22148.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
import std/memfiles
|
||||
|
||||
# bug #22148
|
||||
proc make*(input: string) =
|
||||
var inp = memfiles.open(input)
|
||||
for line in memSlices(inp):
|
||||
let lineF = MemFile(mem: line.data, size: line.size)
|
||||
for word in memSlices(lineF, ','):
|
||||
discard
|
||||
|
||||
make("") # Must call to trigger
|
||||
Reference in New Issue
Block a user