diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-04 10:55:46 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-04 10:55:46 (GMT) |
commit | 2aaf4d1a35792ba7d0d0f217dbda1c1297389f3e (patch) | |
tree | 8e08b2c96fa6421aa456d1a78a7b5ee3692aa283 | |
parent | 7de32cff0f6d209fe5305b4a537ce2b3b2996fa8 (diff) | |
download | Qt-2aaf4d1a35792ba7d0d0f217dbda1c1297389f3e.zip Qt-2aaf4d1a35792ba7d0d0f217dbda1c1297389f3e.tar.gz Qt-2aaf4d1a35792ba7d0d0f217dbda1c1297389f3e.tar.bz2 |
Fix tst_QVariant::operator_eq_eq(UserType)
It was comparing uninitialized memory.
Reviewed-by: Thierry
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qvariant/tst_qvariant.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 95b2352..9a278bd 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -470,6 +470,9 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*') return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr); + if (a->is_null && b->is_null) + return true; + return a_ptr == b_ptr; } diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index b7e2c81..1fd6564 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -1969,7 +1969,7 @@ 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; + QTest::newRow( "UserType" ) << QVariant(QVariant::UserType) << QVariant(QVariant::UserType) << true; QVariant mUserType(QVariant::UserType); QTest::newRow( "Shared UserType" ) << mUserType << mUserType << true; } |