summary refs log tree commit diff stats
path: root/lib/core
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/core
parenta5d6080a81486412e7567658fa816c475e27e42c (diff)
downloadNim-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.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
id='n147' href='#n147'>147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299