Skip to content

Commit

Permalink
WebCore::PathQt::platformPath(): don't return a temporary object
Browse files Browse the repository at this point in the history
`WebCore::Path::platformPath()` expects to be able to return the return
value of `WebCore::PlatformPathImpl::platformPath()` as a
`PlatformPathPtr` without creating a dangling reference. However,
`WebCore::PathQt::platformPath()` is defined as returning a temporary
`QPainterPath` object, which does become a dangling reference when
returned by reference, leading to segfaults at runtime.

This commit changes the return type of `WebCore::PathQt::platformPath()`
to `PlatformPathPtr` (paralleling the definition of
`WebCore::PathCG::platformPath()`), so as to avoid creating a temporary
`QPainterPath` object, thereby avoiding the creation of a dangling
reference when returning from `WebCore::Path::platformPath()`.

Fixes: movableink#37
  • Loading branch information
whitslack committed May 29, 2024
1 parent 2d2b379 commit 3297fc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/qt/PathQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Ref<PathImpl> PathQt::copy() const
return create(m_path);
}

QPainterPath PathQt::platformPath() const
PlatformPathPtr PathQt::platformPath() const
{
return m_path;
}
Expand Down
4 changes: 1 addition & 3 deletions Source/WebCore/platform/graphics/qt/PathQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PathQt final : public PathImpl {
PathQt& operator=(const PathQt&);
PathQt& operator=(PathQt&& other);

QPainterPath platformPath() const;
PlatformPathPtr platformPath() const;

void addPath(const PathQt&, const AffineTransform&);

Expand All @@ -68,8 +68,6 @@ class PathQt final : public PathImpl {
private:
Ref<PathImpl> copy() const final;

QPainterPath ensurePlatformPath() { return platformPath(); }

void add(PathMoveTo) final;

void add(PathLineTo) final;
Expand Down

0 comments on commit 3297fc5

Please sign in to comment.