tst_QMetaType: fix UB (nullptr passed to memcmp()) in selfCompare()
QMetaType::Void is not constructible, so create() will return nullptr, and even though sizeOf() returns 0, calling memcmp() is still UB in that case. Fix by guarding the memcmp() from QMetaType::Void. Amends a59e7361714d50687d82a2d9abae9e95825a23b6. Pick-to: 6.9 6.8 6.5 Change-Id: I55896826e6c0cad5d77e9d0ab861efa9a32f780f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0475bc57d6
commit
c6c2a0bf37
@ -1683,7 +1683,8 @@ void tst_QMetaType::selfCompare()
|
|||||||
case QMetaType::MetaTypeName:
|
case QMetaType::MetaTypeName:
|
||||||
FOR_EACH_PRIMITIVE_METATYPE(ADD_METATYPE_CASE)
|
FOR_EACH_PRIMITIVE_METATYPE(ADD_METATYPE_CASE)
|
||||||
#undef ADD_METATYPE_CASE
|
#undef ADD_METATYPE_CASE
|
||||||
QCOMPARE(memcmp(v1, v2, t.sizeOf()), 0);
|
if (type != QMetaType::Void)
|
||||||
|
QCOMPARE(memcmp(v1, v2, t.sizeOf()), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user