diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-09-12 10:10:00 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-12 10:10:00 +0200 |
commit | b195204549fa99f18fcf1b4d5b757cc5aa7e9a6e (patch) | |
tree | 58a8d71c3dabb77ac3d37f73e28c205b3cae1eaa /lib/system.nim | |
parent | 87955eaf3048bd6b69a988ac330f9d35b2cfa39e (diff) | |
download | Nim-b195204549fa99f18fcf1b4d5b757cc5aa7e9a6e.tar.gz |
Fix add(string, cstring) when the lhs is null (#8951)
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/system.nim b/lib/system.nim index a406c7811..4552c6304 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2741,10 +2741,11 @@ type when defined(JS): proc add*(x: var string, y: cstring) {.asmNoStackFrame.} = asm """ - var len = `x`.length; + if (`x` === null) { `x` = []; } + var off = `x`.length; + `x`.length += `y`.length; for (var i = 0; i < `y`.length; ++i) { - `x`[len] = `y`.charCodeAt(i); - ++len; + `x`[off+i] = `y`.charCodeAt(i); } """ proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".} |