Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 96b78a6

Browse files
committed
[ CID 15953 ] libgraphics: path.cpp: Resource leak in MCGPathMutableCopy
Fixed by freeing the new path on failure and returning nil.
1 parent f7088be commit 96b78a6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

libgraphics/src/path.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,21 @@ void MCGPathCopyAndRelease(MCGPathRef self, MCGPathRef& r_new_path)
161161
void MCGPathMutableCopy(MCGPathRef self, MCGPathRef& r_new_path)
162162
{
163163
MCGPathRef t_new_path;
164-
MCGPathCreateMutable(t_new_path);
165-
if (MCGPathIsValid(t_new_path))
164+
t_new_path = nil;
165+
166+
if (MCGPathIsValid(self))
167+
{
168+
MCGPathCreateMutable(t_new_path);
166169
MCGPathAddPath(t_new_path, self);
170+
}
171+
167172
if (MCGPathIsValid(t_new_path))
168173
r_new_path = t_new_path;
174+
else
175+
{
176+
MCGPathDestroy(t_new_path);
177+
r_new_path = nil;
178+
}
169179
}
170180

171181
void MCGPathMutableCopyAndRelease(MCGPathRef self, MCGPathRef& r_new_path)

0 commit comments

Comments
 (0)