Utils: Fix SmallString reserve for read only references

The capacity of a real only reference is zero but the size is larger than
zero. So if we reserve memory the new capacity has to be bigger than the
size and the capacity.

Change-Id: I8b423da7e7c1cf7cee081d1b3f3464b6fb3f67cf
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Marco Bubke
2016-12-05 12:39:59 +01:00
parent a290850afc
commit b8e391e5f0
2 changed files with 24 additions and 5 deletions

View File

@@ -240,6 +240,7 @@ public:
m_data.allocated.data.capacity = newCapacity;
} else {
const size_type oldSize = size();
newCapacity = std::max(newCapacity, oldSize);
const char *oldData = data();
char *newData = Memory::allocate(newCapacity + 1);