Fix UB in tst_QSharedPointer::basics()
Binding a reference to the nullptr is undefined behavior. Just skip that particular test when 'ptr' is null. Found by UBSan: tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp:258:32: runtime error: reference binding to null pointer of type 'struct Data' Change-Id: I125588b9d269a6f76716d660d03142f409513885 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
9c7be0a7ec
commit
c38b14e251
@ -246,8 +246,10 @@ void tst_QSharedPointer::basics()
|
||||
|
||||
QCOMPARE(ptr.data(), aData);
|
||||
QCOMPARE(ptr.operator->(), aData);
|
||||
Data &dataReference = *ptr;
|
||||
QCOMPARE(&dataReference, aData);
|
||||
if (!isNull) {
|
||||
Data &dataReference = *ptr;
|
||||
QCOMPARE(&dataReference, aData);
|
||||
}
|
||||
|
||||
QVERIFY(ptr == aData);
|
||||
QVERIFY(!(ptr != aData));
|
||||
|
Loading…
x
Reference in New Issue
Block a user