diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-09-19 14:06:11 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-10-17 09:58:56 +0200 |
commit | 9d44645eae144fcfefa0de2455d41f04d29c40d4 (patch) | |
tree | 65159e3a7722714253e13beb408e96e781c72a83 /src/corelib/tools/qarraydatapointer.h | |
parent | f93870ed442df6e8acd068a19ba265ed42e70ee1 (diff) |
Do Q_CHECK_PTR on all results of QArrayData::allocate()
QArrayData::allocate() uses malloc() which can return 0. We need to
check for that when using it inside other containers. The containers
might otherwise return a seemingly valid result from some allocating
operation which is actually corrupt.
Task-number: QTBUG-41231
Change-Id: I16cc6035e4f495f519bd38bf29cee080ee0637f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qarraydatapointer.h')
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index f2cd3ec983..aef38bc20b 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -169,8 +169,10 @@ public: private: Data *clone(QArrayData::AllocationOptions options) const Q_REQUIRED_RESULT { - QArrayDataPointer copy(Data::allocate(d->detachCapacity(d->size), - options)); + Data *x = Data::allocate(d->detachCapacity(d->size), options); + Q_CHECK_PTR(x); + QArrayDataPointer copy(x); + if (d->size) copy->copyAppend(d->begin(), d->end()); |