diff options
author | Jörg Wollenschläger <joerg.wollenschlaeger@gmail.com> | 2019-07-19 23:46:47 +0900 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-07-19 16:46:47 +0200 |
commit | 903d06bab8ba6c5fd2e30fb29dfc327f304f1ae1 (patch) | |
tree | 8f1b9f9c942e1459e2352c7cf9e1360cb3ca1fc8 /lib/core | |
parent | a5d6080a81486412e7567658fa816c475e27e42c (diff) | |
download | Nim-903d06bab8ba6c5fd2e30fb29dfc327f304f1ae1.tar.gz |
Fix the range of destroyed elements when shrinking a seq (#11785)
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/seqs.nim | 2 |
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 |