diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 18066a80ef9..47062fc7882 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -140,7 +140,7 @@ class QVarLengthArray ptr = std::exchange(other.ptr, otherInlineStorage); } else { // inline storage: move into our storage (doesn't matter whether inline or external) - QtPrivate::q_uninitialized_relocate_n(other.ptr, other.s, data()); + QtPrivate::q_uninitialized_relocate_n(other.data(), other.size(), data()); } s = std::exchange(other.s, 0); return *this; @@ -550,8 +550,10 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::reallocate(qsizetype asi if (QTypeInfo::isComplex) { // call default constructor for new objects (which can throw) - while (s < asize) - new (ptr+(s++)) T; + while (size() < asize) { + new (data() + size()) T; + ++s; + } } else { s = asize; }