From c88f58948a81975d2f37b3a233eeaaafbd07ef38 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 4 May 2023 16:42:04 +0200 Subject: [PATCH] fixes #21780 [backport:1.6] (#21785) * fixes #21780 [backport:1.6] * complete patch (cherry picked from commit 79ac242c7206b71ff1ea8ea8d1e499c610a1403f) --- lib/system/seqs_v2.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system/seqs_v2.nim b/lib/system/seqs_v2.nim index 0c487b31d6..e12dada750 100644 --- a/lib/system/seqs_v2.nim +++ b/lib/system/seqs_v2.nim @@ -89,7 +89,7 @@ proc grow*[T](x: var seq[T]; newLen: Natural; value: T) = #sysAssert newLen >= x.len, "invalid newLen parameter for 'grow'" if newLen <= oldLen: return var xu = cast[ptr NimSeqV2[T]](addr x) - if xu.p == nil or xu.p.cap < newLen: + if xu.p == nil or (xu.p.cap and not strlitFlag) < newLen: xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, newLen - oldLen, sizeof(T), alignof(T))) xu.len = newLen for i in oldLen .. newLen-1: @@ -104,7 +104,7 @@ proc add*[T](x: var seq[T]; value: sink T) {.magic: "AppendSeqElem", noSideEffec ## respected. let oldLen = x.len var xu = cast[ptr NimSeqV2[T]](addr x) - if xu.p == nil or xu.p.cap < oldLen+1: + if xu.p == nil or (xu.p.cap and not strlitFlag) < oldLen+1: xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, 1, sizeof(T), alignof(T))) xu.len = oldLen+1 # .nodestroy means `xu.p.data[oldLen] = value` is compiled into a @@ -121,7 +121,7 @@ proc setLen[T](s: var seq[T], newlen: Natural) = let oldLen = s.len if newlen <= oldLen: return var xu = cast[ptr NimSeqV2[T]](addr s) - if xu.p == nil or xu.p.cap < newlen: + if xu.p == nil or (xu.p.cap and not strlitFlag) < newlen: xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, newlen - oldLen, sizeof(T), alignof(T))) xu.len = newlen