summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-29 17:22:30 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-01 15:46:39 +0100
commit38d1444a606679228b2a3c1d743f00225f6c25a1 (patch)
tree17aa355dae8e0bf6ed33aa1d529997e62df5c1b3 /src/corelib/kernel/qmetatype.cpp
parentd6a8560eaeedf889c01f2192b31a4ebf8e8f7fb9 (diff)
Do delete on QMetaType::destroy() even without dtor
As we call operator new on create(), we also need to delete on destroy(). Otherwise we leak memory. Change-Id: Ib80fe96c4173cba6fa474d3c81d88fe603d1ded2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r--src/corelib/kernel/qmetatype.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 859a8946a4..06dbdbde18 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -594,8 +594,9 @@ void *QMetaType::create(const void *copy) const
*/
void QMetaType::destroy(void *data) const
{
- if (d_ptr && d_ptr->dtor) {
- d_ptr->dtor(d_ptr, data);
+ if (d_ptr) {
+ if (d_ptr->dtor)
+ d_ptr->dtor(d_ptr, data);
if (d_ptr->alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__) {
operator delete(data, std::align_val_t(d_ptr->alignment));
} else {