diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 18facf7e42..faa7263d6b 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -211,6 +211,7 @@ void QContiguousCache::detach_helper() template void QContiguousCache::setCapacity(int asize) { + Q_ASSERT(asize >= 0); if (asize == d->alloc) return; detach(); @@ -285,6 +286,7 @@ inline QContiguousCacheData *QContiguousCache::allocateData(int aalloc) template QContiguousCache::QContiguousCache(int cap) { + Q_ASSERT(cap >= 0); d = allocateData(cap); d->ref.store(1); d->alloc = cap;