diff options
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 2998244..8c31f40 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -204,7 +204,9 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a if (QTypeInfo<T>::isStatic) { QT_TRY { - while (s < asize) { + // copy all the old elements + const int copySize = qMin(asize, osize); + while (s < copySize) { new (ptr+s) T(*(oldPtr+s)); (oldPtr+s)->~T(); s++; |