Open rivera-ernesto opened 10 years ago
Nice catch. But we can't simply CFRelease(currentFont)
as it would crash in the case the previous line did return a non-nil CFFont (if we don't enter the if
)…
To avoid a crash here if we add a CFRelease
later, we need to CFRetain
it when it's non-nil
(in an else
condition corresponding to this if
statement), so that the CFRelease
will balance the retain count in both situations (either when we get it from the attribute then retain it, or if we CTFontCreate
it directly)
Xcode 5 analyzer warns about a potential leak of
currentFont
inNSAttributedString+Attributes.m
here.It seems that a simple
CFRelease(currentFont)
would fix it.