summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydatapointer.h
diff options
context:
space:
mode:
authorDennis Oberst <dennis.oberst@qt.io>2023-05-30 17:22:07 +0200
committerDennis Oberst <dennis.oberst@qt.io>2023-05-30 16:50:54 +0000
commit2d77051f9dfd11ae292ad4bac2f28c5f7a0e7f83 (patch)
tree51f851f94d3f554fb8813aa45385b524b554b756 /src/corelib/tools/qarraydatapointer.h
parent574cf24a6531ca4fd69e9f989d86074b0f52bd82 (diff)
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>
Diffstat (limited to 'src/corelib/tools/qarraydatapointer.h')
-rw-r--r--src/corelib/tools/qarraydatapointer.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index 466cdecfc7d..eb6ceeafeef 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -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
}