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 3d575d4845

Change-Id: Ia31bccd5b41fe090c29df1aeaa69efb706cd25bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jędrzej Nowacki 2016-01-15 16:07:04 +01:00
parent 1e370a45bf
commit ad77422e82

View File

@ -1698,8 +1698,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
void *QMetaType::create(int type, const void *copy) void *QMetaType::create(int type, const void *copy)
{ {
QMetaType info(type); QMetaType info(type);
int size = info.sizeOf(); if (int size = info.sizeOf())
return info.construct(operator new(size), copy); return info.construct(operator new(size), copy);
return 0;
} }
/*! /*!