summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2023-04-25 14:30:44 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2023-05-10 16:53:13 +0200
commit86a0e70d65f406359e36b1a0f714a8ff3e5394e1 (patch)
tree4bdaa62e2de56d3e83fdf6eb89358190f5321565 /src/gui/painting
parent311f8157ae1aa77a0fb0154e8207678a0d919703 (diff)
QDataBuffer: decrease size on shrink()
Having the size potentially be larger than the capacity can't be considered anything other than a bug. Pick-to: 6.5 Change-Id: Id059c0f2c7320f992d897011d7aa944c5cb86058 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qdatabuffer_p.h3
1 files changed, 3 insertions, 0 deletions
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<void*>(buffer), capacity * sizeof(Type));
Q_CHECK_PTR(buffer);
+ siz = std::min(siz, size);
} else {
free(buffer);
buffer = nullptr;
+ siz = 0;
}
}