summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/system/gc_ms.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim
index db437b8d0..410243528 100644
--- a/lib/system/gc_ms.nim
+++ b/lib/system/gc_ms.nim
@@ -143,7 +143,7 @@ proc nimGCref(p: pointer) {.compilerProc.} =
 
 proc nimGCunref(p: pointer) {.compilerProc.} =
   let cell = usrToCell(p)
-  var L = gch.additionalRoots.len
+  var L = gch.additionalRoots.len-1
   var i = L
   let d = gch.additionalRoots.d
   while i >= 0:
@@ -151,6 +151,7 @@ proc nimGCunref(p: pointer) {.compilerProc.} =
       d[i] = d[L]
       dec gch.additionalRoots.len
       break
+    dec(i)
   when false:
     when withBitvectors: incl(gch.allocated, usrToCell(p))
     else: usrToCell(p).refcount = rcWhite