From a4d7572059b5b56d49d7e0c3f3466686e1dc6e16 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 3 Mar 2010 20:47:13 +0100 Subject: QVariant: Fix crash when comparing two variant with the same undefined type. If the type is the same, but not registered, the returned string could be null (or empty if a empty string was registered) In that case, QVariant compare() function would access invalid memory. Protect against that case. qstrcmp returns 0 if 0 is given as a parametter. Task-number: QTBUG-8700 Reviewed-by: Markus Goetz --- tests/auto/qvariant/tst_qvariant.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index a316dda637..b7e2c81e98 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -1968,6 +1968,10 @@ void tst_QVariant::operator_eq_eq_data() QTest::newRow("HashSecondLarger") << QVariant(hash1) << QVariant(hash2) << false; } + + QTest::newRow( "UserType" ) << QVariant(QVariant::UserType) << QVariant(QVariant::UserType) << false; + QVariant mUserType(QVariant::UserType); + QTest::newRow( "Shared UserType" ) << mUserType << mUserType << true; } void tst_QVariant::operator_eq_eq() -- cgit v1.2.3