QArrayDataPointer: add missing Q_CHECK_PTR check in assign()

The previous implementation of iterator-assign did not include a check
for the return value of QArrayData::allocate(~), which returns a nullptr
on failure.

Amends: bbbe5f45c4.

Change-Id: I219e63ecd6de4225364d9c3dd2006ddbbe47068f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Dennis Oberst 2023-05-30 17:22:07 +02:00
parent 574cf24a65
commit 2d77051f9d

View File

@ -320,10 +320,12 @@ public:
const qsizetype n = std::distance(first, last);
if (needsDetach() || n > constAllocatedCapacity()) {
QArrayDataPointer allocated(Data::allocate(detachCapacity(n)));
Q_CHECK_PTR(allocated.data());
swap(allocated);
}
} else if (needsDetach()) {
QArrayDataPointer allocated(Data::allocate(allocatedCapacity()));
Q_CHECK_PTR(allocated.data());
swap(allocated);
// We don't want to copy data that we know we'll overwrite
}