diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index fdd3fbc4a7..3ddf192c16 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -115,10 +115,13 @@ proc cstrToNimstr(str: cstring): NimString {.compilerRtl.} = else: toNimStr(str, str.len) proc moveString(src: NimString): NimString {.compilerRtl.} = - if (src.reserved and strlitFlag) != 0: - result = toOwnedCopy(src) - else: + if src == nil: result = src + else: + if (src.reserved and strlitFlag) != 0: + result = toOwnedCopy(src) + else: + result = src proc copyString(src: NimString): NimString {.compilerRtl.} = ## Expects `src` to be initialized (len and terminating zero set)