Don't dereference pointers on QArrayData deallocation

If the allocation fails the pointer will be 0. That is OK for free(),
but we shouldn't try to check for static data then.

Change-Id: I0a8860c9e04833e3be79f7a8a39bdaffeb488f35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Ulf Hermann 2014-09-19 16:11:51 +02:00 committed by Marc Mutz
parent 9d44645eae
commit 9eb2b25300
1 changed files with 2 additions and 1 deletions

View File

@ -118,7 +118,8 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize,
return;
#endif
Q_ASSERT_X(!data->ref.isStatic(), "QArrayData::deallocate", "Static data can not be deleted");
Q_ASSERT_X(data == 0 || !data->ref.isStatic(), "QArrayData::deallocate",
"Static data can not be deleted");
::free(data);
}