-
Notifications
You must be signed in to change notification settings - Fork 808
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
Fix leak in NSRunLoop _statesForMode: helper #1793
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
- (void)_removeInputSource:(NSInputSource*)source forMode:(NSString*)mode; | ||
- (void)_addObserver:(NSObject*)observer forMode:(NSString*)mode; | ||
- (void)_removeObserver:(NSObject*)observer forMode:(NSString*)mode; | ||
- (StrongId<NSArray*>)_statesForMode:(NSString*)mode; | ||
- (StrongId<NSArray>)_statesForMode:(NSString*)mode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it could be a better solution to simply make that return an autoreleased thing, and drop the StrongId from each of its consumers. Feel free to go either way! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would kind of prefer to stick with returning a StrongId since it's a cool way to avoid the autorelease pool (though forgetting to assign the call to a StrongId is a big use-after-free footgun). Since it turns out _statesForMode is only used in NSRunLoop.mm I'm thinking the best option is to remove the method declaration from the header but keep it returning a StrongId. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing the declaration of _statesForMode from the +Internal header would've required another declaration in a class extension in the .mm.... so just went with the autorelease after all. |
||
- (void)_processMainRunLoop:(int)value; | ||
- (void)_shutdown; | ||
- (void)removeTimer:(NSTimer*)timer forMode:(NSString*)mode; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: disprefer returning these C++ things across API boundaries; use an autoreleased NSArray* instead 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I see. This wasn't initially your code.
I'll downgrade it to a non-showstopper, but it might make the memory management here easier to reckon about.