Fix crash in QPainterPath::reserve()

Function did not handle default-constructed (null d_ptr) path correctly.

Fixes: QTBUG-76516
Change-Id: I2925d4306f7fce34ece6739b18a8e275e7970837
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Eirik Aavitsland 2019-06-19 16:35:28 +02:00
parent 71ed62bc4c
commit 2ce4a9f487
2 changed files with 6 additions and 1 deletions

View File

@ -675,8 +675,9 @@ void QPainterPath::reserve(int size)
{
Q_D(QPainterPath);
if ((!d && size > 0) || (d && d->elements.capacity() < size)) {
ensureData();
detach();
d->elements.reserve(size);
d_func()->elements.reserve(size);
}
}

View File

@ -189,6 +189,10 @@ void tst_QPainterPath::reserveAndCapacity()
p.reserve(0);
QVERIFY(p.capacity() >= 1000);
QPainterPath p2;
p2.reserve(10);
QVERIFY(p.capacity() >= 10);
}
Q_DECLARE_METATYPE(QPainterPath)