summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2016-01-15 16:07:04 +0100
committerJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2016-02-01 07:35:16 +0000
commitad77422e824df3556984b793d5b304a87d7c757b (patch)
tree5f1fa4a74bea630d83c781bed14b65ca65253980
parent1e370a45bf2cc770371026c3ad05d4f7d26be3a0 (diff)
Fix memory leak if QMetaType::create is called for an unknown type
The memory should be allocated only if we operates on a valid type, It is a regression introduced by 3d575d4845926bd141ff0c14e57427bba79644d0 Change-Id: Ia31bccd5b41fe090c29df1aeaa69efb706cd25bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-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 e6d745bb74..dc6e3737b6 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1698,8 +1698,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
void *QMetaType::create(int type, const void *copy)
{
QMetaType info(type);
- int size = info.sizeOf();
- return info.construct(operator new(size), copy);
+ if (int size = info.sizeOf())
+ return info.construct(operator new(size), copy);
+ return 0;
}
/*!