summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qbytearray.cpp3
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 121f45f..b91b0f2 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -69,6 +69,9 @@ int qFindByteArray(
int qAllocMore(int alloc, int extra)
{
+ Q_ASSERT(alloc >= 0 && extra >= 0);
+ Q_ASSERT_X(alloc < (1 << 30) - extra, "qAllocMore", "Requested size is too large!");
+
if (alloc == 0 && extra == 0)
return 0;
const int page = 1 << 12;
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 1363dbf..e63a0aba 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -1116,9 +1116,7 @@ void tst_QByteArray::toULongLong()
void tst_QByteArray::qAllocMore()
{
static const int t[] = {
- INT_MIN, INT_MIN + 1, -1234567, -66000, -1025,
- -3, -1, 0, +1, +3, +1025, +66000, +1234567, INT_MAX - 1, INT_MAX,
- INT_MAX/3
+ 0, +1, +3, +1025, +66000, +1234567, INT_MAX/4
};
static const int N = sizeof(t)/sizeof(t[0]);