summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorJörg Wollenschläger <joerg.wollenschlaeger@gmail.com>2019-07-19 23:46:47 +0900
committerAndreas Rumpf <rumpf_a@web.de>2019-07-19 16:46:47 +0200
commit903d06bab8ba6c5fd2e30fb29dfc327f304f1ae1 (patch)
tree8f1b9f9c942e1459e2352c7cf9e1360cb3ca1fc8 /lib
parenta5d6080a81486412e7567658fa816c475e27e42c (diff)
downloadNim-903d06bab8ba6c5fd2e30fb29dfc327f304f1ae1.tar.gz
Fix the range of destroyed elements when shrinking a seq (#11785)
Diffstat (limited to 'lib')
-rw-r--r--lib/core/seqs.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/core/seqs.nim b/lib/core/seqs.nim
index bbbcf069e..2892e4d8a 100644
--- a/lib/core/seqs.nim
+++ b/lib/core/seqs.nim
@@ -138,7 +138,7 @@ proc shrink*[T](x: var seq[T]; newLen: Natural) =
   mixin `=destroy`
   sysAssert newLen <= x.len, "invalid newLen parameter for 'shrink'"
   when not supportsCopyMem(T):
-    for i in countdown(x.len - 1, newLen - 1):
+    for i in countdown(x.len - 1, newLen):
       `=destroy`(x[i])
   # XXX This is wrong for const seqs that were moved into 'x'!
   cast[ptr NimSeqV2[T]](addr x).len = newLen