The function is public, so it should validate input instead of crashing
Change-Id: Id67463b0b61ab74a76c1ede7f052bdbed37822b6
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
static quint32 customTypeFlags(const int type)
{
const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (Q_UNLIKELY(!ct))
+ if (Q_UNLIKELY(!ct || type < QMetaType::User))
return 0;
QReadLocker locker(customTypesLock());
if (Q_UNLIKELY(ct->count() <= type - QMetaType::User))
QTest::newRow("QPair<P,C>") << ::qMetaTypeId<QPair<P,C> >() << false << true << false;
QTest::newRow("QPair<P,M>") << ::qMetaTypeId<QPair<P,M> >() << true << true << false;
QTest::newRow("QPair<P,P>") << ::qMetaTypeId<QPair<P,P> >() << true << false << false;
+
+ // invalid ids.
+ QTest::newRow("-1") << -1 << false << false << false;
+ QTest::newRow("-124125534") << -124125534 << false << false << false;
+ QTest::newRow("124125534") << 124125534 << false << false << false;
+
}
void tst_QMetaType::flags()