Skip to content

Commit

Permalink
Fix crash in QPainterPath::reserve()
Browse files Browse the repository at this point in the history
Function did not handle default-constructed (null d_ptr) path correctly.

Fixes: QTBUG-76516
Change-Id: I2925d4306f7fce34ece6739b18a8e275e7970837
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
  • Loading branch information
aavit committed Jun 19, 2019
1 parent 71ed62b commit 2ce4a9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gui/painting/qpainterpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ce4a9f

Please sign in to comment.