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>
This commit is contained in:
parent
311f8157ae
commit
86a0e70d65
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user