summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Svetkin <mikhail.svetkin@qt.io>2018-04-09 14:20:44 +0200
committerMikhail Svetkin <mikhail.svetkin@qt.io>2018-04-10 17:47:57 +0000
commitb50b654ba4c1c2a59ae80420ed77e09d1080707b (patch)
tree0f3b36a304e0f0324f16633a8fb68397dbb4298f
parenta5771345d9357d9d5ba65764c3aad3233df7fb6e (diff)
Fix integer overflow (1 << (' ' - 1))
On platforms where integer by default is int32(max is 2147483647) and (1 << (' ' - 1)) will be 2147483648 Change-Id: I790d33bd4e473925d6897dd87cbffdfe8dd7938f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 28f9b35b35e7c9964f22f4e28aac9c6093401900)
-rw-r--r--src/corelib/tools/qlocale_p.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index f7adb021b6..993230e184 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -427,15 +427,15 @@ QString qt_readEscapedFormatString(const QString &format, int *idx);
bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry);
int qt_repeatCount(const QString &s, int i);
-enum { AsciiSpaceMask = (1 << (' ' - 1)) |
- (1 << ('\t' - 1)) | // 9: HT - horizontal tab
- (1 << ('\n' - 1)) | // 10: LF - line feed
- (1 << ('\v' - 1)) | // 11: VT - vertical tab
- (1 << ('\f' - 1)) | // 12: FF - form feed
- (1 << ('\r' - 1)) }; // 13: CR - carriage return
+enum { AsciiSpaceMask = (1u << (' ' - 1)) |
+ (1u << ('\t' - 1)) | // 9: HT - horizontal tab
+ (1u << ('\n' - 1)) | // 10: LF - line feed
+ (1u << ('\v' - 1)) | // 11: VT - vertical tab
+ (1u << ('\f' - 1)) | // 12: FF - form feed
+ (1u << ('\r' - 1)) }; // 13: CR - carriage return
Q_DECL_CONSTEXPR inline bool ascii_isspace(uchar c)
{
- return c >= 1U && c <= 32U && (uint(AsciiSpaceMask) >> uint(c - 1)) & 1U;
+ return c >= 1u && c <= 32u && (AsciiSpaceMask >> uint(c - 1)) & 1u;
}
#if defined(Q_COMPILER_CONSTEXPR)