From 2d77051f9dfd11ae292ad4bac2f28c5f7a0e7f83 Mon Sep 17 00:00:00 2001 From: Dennis Oberst Date: Tue, 30 May 2023 17:22:07 +0200 Subject: [PATCH] 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 Reviewed-by: Ivan Solovev --- src/corelib/tools/qarraydatapointer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 466cdecfc7..eb6ceeafee 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 }