QOrderedMutexLocker: fix UB (pointer comparison with <) in static relock()

Comparing pointers that do not point into the same array using
operator< is UB. You need to use std::less<>.

The QOrderedMutexLocker ctor already used std::less to compare
pointers, but the static relock() function was not fixed.

Amends 5007352164.

Change-Id: I584d382391dd5a2af75020a4e77f3e42ee5d5708
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Marc Mutz 2016-10-14 10:40:56 +02:00 committed by Tim Jenssen
parent 983d9e0c1a
commit ed5d04fcfc

View File

@ -93,7 +93,7 @@ public:
// mtx1 is already locked, mtx2 not... do we need to unlock and relock?
if (mtx1 == mtx2)
return false;
if (mtx1 < mtx2) {
if (std::less<QMutex *>()(mtx1, mtx2)) {
mtx2->lock();
return true;
}