Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.12.1
-
None
-
7831b276e610368514087a81396d1ca2425b2e42 (qt/qtbase/5.12)
Description
QCollator on Windows uses CompareString(Ex). These methods return 0 on error (source). However, QCollator does not check for this return value (source: qcollator_win.cpp:97). Instead, if a flag is not supported, it returns a negative number for any comparison.
Note that a comparator function with this behavior leads std::sort() to go out-of-bounds with iterators and crash the program.
This can be observed when testing an application with WINE, which does not support SORT_DIGITSASNUMBERS flag. WINE correctly implements CompareStringEx according to Microsoft's documentation (source). For historical context, see also this commit.