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: bbbe5f45c4d354ef977d4e09459ef5ae4d6db0da. Change-Id: I219e63ecd6de4225364d9c3dd2006ddbbe47068f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
574cf24a65
commit
2d77051f9d
@ -320,10 +320,12 @@ public:
|
|||||||
const qsizetype n = std::distance(first, last);
|
const qsizetype n = std::distance(first, last);
|
||||||
if (needsDetach() || n > constAllocatedCapacity()) {
|
if (needsDetach() || n > constAllocatedCapacity()) {
|
||||||
QArrayDataPointer allocated(Data::allocate(detachCapacity(n)));
|
QArrayDataPointer allocated(Data::allocate(detachCapacity(n)));
|
||||||
|
Q_CHECK_PTR(allocated.data());
|
||||||
swap(allocated);
|
swap(allocated);
|
||||||
}
|
}
|
||||||
} else if (needsDetach()) {
|
} else if (needsDetach()) {
|
||||||
QArrayDataPointer allocated(Data::allocate(allocatedCapacity()));
|
QArrayDataPointer allocated(Data::allocate(allocatedCapacity()));
|
||||||
|
Q_CHECK_PTR(allocated.data());
|
||||||
swap(allocated);
|
swap(allocated);
|
||||||
// We don't want to copy data that we know we'll overwrite
|
// We don't want to copy data that we know we'll overwrite
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user