Bug 141614 - [iOS] Possible Block Leak WKAutoCorrectionData.autocorrectionContextHandler
Summary: [iOS] Possible Block Leak WKAutoCorrectionData.autocorrectionContextHandler
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-14 19:14 PST by Joseph Pecoraro
Modified: 2015-02-14 19:14 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-02-14 19:14:06 PST
* SUMMARY
Possible Block Leak WKAutoCorrectionData.autocorrectionContextHandler.

Auditing the code, it looks like this block can be assigned a copy that is never released by anyone:

        _autocorrectionData.autocorrectionContextHandler = [completionHandler copy];
        _page->requestAutocorrectionContext([self](...) {
            _autocorrectionData.autocorrectionContextHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
        });

Looks like we should be releasing (and probably niling) _autocorrectionData.autocorrectionContextHandler. Or better yet, don't store these on the struct at all, and just capture them inside the block/lambda.

All of the blocks assigned to WKAutoCorrectionData have sketchy lifetimes. They can are always set on the struct without clearing any possible value that may have been there before. Is there a guarantee that they won't be overwritten?