fixes #26007; apply #24703 self-append fix to the refc string runtime (#26009)

Fix appendString to avoid writing extra null terminator.
This commit is contained in:
Alfred Morgan
2026-07-14 21:50:32 -07:00
committed by GitHub
parent ddcaed7f70
commit 2463ef970d

View File

@@ -223,8 +223,9 @@ proc addChar(s: NimString, c: char): NimString =
proc appendString(dest, src: NimString) {.compilerproc, inline.} =
## Raw, does not prepare `dest` space for copying
if src != nil:
copyMem(addr(dest.data[dest.len]), addr(src.data), src.len + 1)
copyMem(addr(dest.data[dest.len]), addr(src.data), src.len)
inc(dest.len, src.len)
dest.data[dest.len] = '\0'
proc setLengthStr(s: NimString, newLen: int): NimString {.compilerRtl.} =
## Sets the `s` length to `newLen` zeroing memory on growth.