diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index 1e62c8d924..8f467afe4e 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -89,13 +89,16 @@ public: } void shrink(qsizetype size) { + Q_ASSERT(capacity >= size); capacity = size; if (size) { buffer = (Type*) realloc(static_cast(buffer), capacity * sizeof(Type)); Q_CHECK_PTR(buffer); + siz = std::min(siz, size); } else { free(buffer); buffer = nullptr; + siz = 0; } }