diff options
author | Araq <rumpf_a@web.de> | 2019-04-09 12:20:10 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-04-09 12:20:10 +0200 |
commit | 2430521c846ea1506936f6d7f6ad730ecfa9a26a (patch) | |
tree | f81d015e0c5e76ddee88a7925ab755efbdc5440a /lib/core | |
parent | 32ad3bb2361aa75a11d103f6564e104298f386fc (diff) | |
download | Nim-2430521c846ea1506936f6d7f6ad730ecfa9a26a.tar.gz |
newruntime: fixes memory leak
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/strs.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/core/strs.nim b/lib/core/strs.nim index f02757070..767e897c8 100644 --- a/lib/core/strs.nim +++ b/lib/core/strs.nim @@ -163,11 +163,12 @@ proc mnewString(len: int): NimStringV2 {.compilerProc.} = result = NimStringV2(len: len, p: p) proc setLengthStrV2(s: var NimStringV2, newLen: int) {.compilerRtl.} = - if newLen > s.len or isLiteral(s): + if newLen == 0: + frees(s) + s.p = nil + elif newLen > s.len or isLiteral(s): prepareAdd(s, newLen - s.len) s.len = newLen - # this also only works because the destructor - # looks at s.p and not s.len proc nimAsgnStrV2(a: var NimStringV2, b: NimStringV2) {.compilerRtl.} = # self assignment is fine! |