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

Commit 5dc5908

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libgraphics/src/path.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ bool MCGPathIsEqualTo(MCGPathRef a, MCGPathRef b)
118118

119119
void MCGPathCopy(MCGPathRef self, MCGPathRef& r_new_path)
120120
{
121-
if(!self -> is_mutable)
121+
if (!MCGPathIsValid(self))
122+
r_new_path = nil;
123+
else if(!self -> is_mutable)
122124
r_new_path = MCGPathRetain(self);
123125
else
124126
{
@@ -131,6 +133,11 @@ void MCGPathCopy(MCGPathRef self, MCGPathRef& r_new_path)
131133
t_new_path -> is_mutable = false;
132134
r_new_path = t_new_path;
133135
}
136+
else
137+
{
138+
MCGPathDestroy(t_new_path);
139+
r_new_path = nil;
140+
}
134141
}
135142
}
136143

0 commit comments

Comments
 (0)