qt6-bb10/tests/auto/corelib
Thiago Macieira ae44b283a9 tst_QStringConverter: compare pointer distances, not pointers
Strictly speaking, we did want to compare pointers, but char* are
special with QCOMPARE in that the pointed-to strings are compared, not
the pointers. So this wasn't doing what we wanted it to do.

We could static_cast to void* to do it, but subtracting one from the
other also gets us what we want, with simpler code. The drawback is that
if appendToBuffer() ever returns nullptr, we'll print a huge number as
the offset.

Found by Valgrind:
==3769588== Conditional jump or move depends on uninitialised value(s)
==3769588==    at 0x483FEDC: strcmp (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3769588==    by 0x4C41EB6: qstrcmp(char const*, char const*) (in lib/libQt6Core.so.6.9.0)
==3769588==    by 0x48975D8: QTest::compare_string_helper(char const*, char const*, char const*, char const*, char const*, int) (in lib/libQt6Test.so.6.9.0)
==3769588==    by 0x12B12A: QTest::qCompare(char*, char*, char const*, char const*, char const*, int) (in tests/auto/corelib/text/qstringconverter/tst_qstringconverter)
==3769588==    by 0x10EE94: tst_QStringConverter::invalidConverter() (in tests/auto/corelib/text/qstringconverter/tst_qstringconverter)

Amends c46ee7df57.

Pick-to: 6.7 6.5 6.2
Fixes: QTBUG-126107
Change-Id: I44265a5eb67e47a59fc8fffd17d64051657af529
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 9d5611dc97979dab1932b07f8cfab367c3872d24)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-07 06:59:22 +00:00
..
animation Change license for tests files 2024-02-04 09:56:42 +01:00
global totally_ordered_wrapper: add reset(P) function 2024-06-07 06:59:21 +00:00
io tst_qprocess: Add crash helper for MSVC ARM64 2024-06-04 11:19:01 +00:00
ipc QNativeIpcKey: use new comparison helper macros 2024-04-17 20:30:37 +02:00
itemmodels Port QPersistentModelIndex to new comparison helper macros 2024-05-24 22:17:46 +02:00
kernel qtypeinfo.h: move QTypeTraits part to qttypetraits.h 2024-06-04 13:42:16 +00:00
mimetypes QMimeType: use modernize comparisons 2024-04-30 17:46:34 +02:00
platform tst_qcomobject: Reduce size of Qt-namespace 2024-05-13 15:25:36 +02:00
plugin Add copyright and licensing to .cpp and .h files missing them 2024-05-28 09:47:01 +02:00
serialization Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
text tst_QStringConverter: compare pointer distances, not pointers 2024-06-07 06:59:22 +00:00
thread QtPrivate::ResultIteratorBase: use modernize comparisons 2024-05-14 00:32:35 +02:00
time Update CLDR Windows timezone data to v44.1 2024-06-02 15:25:00 +02:00
tools Long live QCryptographicHash::hashInto()! 2024-05-29 14:24:29 +02:00
CMakeLists.txt