Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential leak in NSAttributedString+Attributes #173

Open
rivera-ernesto opened this issue Jan 17, 2014 · 1 comment
Open

Potential leak in NSAttributedString+Attributes #173

rivera-ernesto opened this issue Jan 17, 2014 · 1 comment

Comments

@rivera-ernesto
Copy link

Xcode 5 analyzer warns about a potential leak of currentFont in NSAttributedString+Attributes.m here.

OHAttributedLabel/Source/NSAttributedString+Attributes.m:276:7: Potential leak of an object stored into 'currentFont'

It seems that a simple CFRelease(currentFont) would fix it.

@AliSoftware
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants