mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fixes a long standing nil bug in substr
This commit is contained in:
@@ -95,6 +95,7 @@ proc mnewString(len: int): NimString {.compilerProc.} =
|
||||
|
||||
proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} =
|
||||
let start = max(start, 0)
|
||||
if s == nil: return nil
|
||||
let len = min(last, s.len-1) - start + 1
|
||||
if len > 0:
|
||||
result = rawNewStringNoInit(len)
|
||||
|
||||
Reference in New Issue
Block a user