Skip to content

Commit 5f9312a

Browse files
committed
Merge pull request #691 from iSevenDays/patch-1
Fixing memory leak
2 parents 7cb4559 + f923993 commit 5f9312a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cocos2d/Support/CCColor.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ - (CCColor*) initWithUIColor:(UIColor *)color
170170
}
171171
#endif
172172

173+
/// After using you must call CGColorRelease(color)
173174
- (CGColorRef) CGColor
174175
{
175176
CGFloat components[4] = {(CGFloat)_r, (CGFloat)_g, (CGFloat)_b, (CGFloat)_a};
176-
return CGColorCreate(CGColorSpaceCreateDeviceRGB(), components);
177+
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
178+
CGColorRef color = CGColorCreate(colorspace, components);
179+
CGColorSpaceRelease(colorspace);
180+
return color;
177181
}
178182

179183
#ifdef __CC_PLATFORM_IOS

0 commit comments

Comments
 (0)