diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-01-18 13:43:37 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-01-19 10:41:22 +0100 |
commit | 390ea21873cf229447c2dcaea85a40e472fab03c (patch) | |
tree | 6e08077694cadbc4d4d4083278d6a459fc72fc56 /src/corelib/tools | |
parent | b18e6396bde2931a302b8fa5910268e23590c8a8 (diff) |
QByteArrayMatcher: fix undefined shift
The REHASH macro is used in qFindByteArray() with a char argument.
Applying the shift operator promotes (a) to int. The check in
REHASH, however, checks for the shift being permissible for
_unsigned_ ints.
Since hashHaystack is a uint, too, rectify by casting (a) to
uint prior to shifting.
Found by UBSan:
src/corelib/tools/qbytearraymatcher.cpp:314:72: runtime error: left shift of 34 by 30 places cannot be represented in type 'int'
Change-Id: Id09c037d570ca70b49f87ad22bed31bbb7dcc7fb
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbytearraymatcher.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index f14d941c27..82f012be66 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -256,7 +256,7 @@ static int qFindByteArrayBoyerMoore( #define REHASH(a) \ if (sl_minus_1 < sizeof(uint) * CHAR_BIT) \ - hashHaystack -= (a) << sl_minus_1; \ + hashHaystack -= uint(a) << sl_minus_1; \ hashHaystack <<= 1 /*! |