summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qtools_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-09-19 16:12:24 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-10-17 10:09:18 +0200
commit880986be2357a1f80827d038d770dc2f80300201 (patch)
tree734cf9684d0b7f1cca65fc3e036e30a108d582f6 /src/corelib/tools/qtools_p.h
parent9eb2b25300c21df2abd9b174c1077a377a42fcd1 (diff)
Check for integer overflows in places where qAllocMore is used
Task-number: QTBUG-41230 Change-Id: I5e932c2540c0bd67f13fab3ae20975d459f82c08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qtools_p.h')
-rw-r--r--src/corelib/tools/qtools_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 3876d3822c..1e72db1d87 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -46,9 +46,15 @@
//
#include "QtCore/qglobal.h"
+#include <limits>
QT_BEGIN_NAMESPACE
+// We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size.
+enum {
+ MaxAllocSize = (1 << (std::numeric_limits<int>::digits - 1)) - 1
+};
+
// implemented in qbytearray.cpp
int Q_CORE_EXPORT qAllocMore(int alloc, int extra) Q_DECL_NOTHROW;