From 53566f716501fe906b8b2aa4ce050be5d6eb0364 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 30 Jul 2018 23:27:01 +0200 Subject: fixes #7833; still to-do: fix setLen --- lib/system/gc.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/system') diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 425963f3f..74ac68eea 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -548,7 +548,10 @@ proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = gcTrace(res, csAllocated) track("growObj old", ol, 0) track("growObj new", res, newsize) - when reallyDealloc: + when defined(nimIncrSeqV3): + # since we steal the old seq's contents, we set the old length to 0. + cast[PGenericSeq](old).len = 0 + elif reallyDealloc: sysAssert(allocInv(gch.region), "growObj before dealloc") if ol.refcount shr rcShift <=% 1: # free immediately to save space: -- cgit 1.4.1-2-gfad0