diff options
Diffstat (limited to 'src/gui/painting/qdatabuffer_p.h')
-rw-r--r-- | src/gui/painting/qdatabuffer_p.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index 1e62c8d924..aa8335542d 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -16,7 +16,9 @@ // #include <QtGui/private/qtguiglobal_p.h> + #include "QtCore/qbytearray.h" +#include "QtCore/qtypeinfo.h" #include <stdlib.h> @@ -43,6 +45,7 @@ public: ~QDataBuffer() { + static_assert(!QTypeInfo<Type>::isComplex); if (buffer) free(buffer); } @@ -89,13 +92,16 @@ public: } void shrink(qsizetype size) { + Q_ASSERT(capacity >= size); capacity = size; if (size) { buffer = (Type*) realloc(static_cast<void*>(buffer), capacity * sizeof(Type)); Q_CHECK_PTR(buffer); + siz = std::min(siz, size); } else { free(buffer); buffer = nullptr; + siz = 0; } } |