Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
5.15.18
Description
For 5.15.x, QMap is mixing quint64 (p) and int (elements in enum) and doing bitwise operation between them, i.e.:
https://github.com/qt/qtbase/blob/v5.15.16-lts-lgpl/src/corelib/tools/qmap.h#L94C5-L94C77
And that may lead to undefined behavior when, e.g. ~Black a negative integer, is promoted to quint64 and causes overflow.
A reproducer is attached, and it is said that the undefined behavior sanitizer that comes with Clang 12 can capture it with such output:
Qt-5/include/QtCore/qmap.h:94:68: runtime error: implicit conversion from type 'int' of value -2 (32-bit, signed) to type 'unsigned long long' changed the value to 18446744073709551614 (64-bit, unsigned) Qt-5/include/QtCore/qmap.h:95:80: runtime error: implicit conversion from type 'int' of value -4 (32-bit, signed) to type 'unsigned long long' changed the value to 18446744073709551612 (64-bit, unsigned)
Notice that it can be compiler specific. My gcc 11.4 UBSAN does not detect anything. Older Clang may not detect anything either.
A patch is also uploaded. We may consider merge it, or at least verify if it's valid.