mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-02 05:29:01 +00:00
Fix appendString to avoid writing extra null terminator.
(cherry picked from commit 2463ef970d)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user