Bug 209980 - REGRESSION (r8412): Use RetainPtr<> for NSMutableAttributedString in -[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:spellCheck:]
Summary: REGRESSION (r8412): Use RetainPtr<> for NSMutableAttributedString in -[WebAcc...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
Keywords: InRadar
Depends on:
Reported: 2020-04-03 12:10 PDT by David Kilzer (:ddkilzer)
Modified: 2020-04-03 12:50 PDT (History)
10 users (show)

See Also:

Patch v1 (3.40 KB, patch)
2020-04-03 12:12 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch for landing (3.36 KB, patch)
2020-04-03 12:24 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2020-04-03 12:10:44 PDT
Way back in 2005 in commit r8412, David Harrison added this line of code to WebCore/kwq/KWQAccObject.mm that was never changed to use RetainPtr<>:

    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init];

This lack of RetainPtr<> caused a leak when Darin landed a fix for Bug 209129.

I fixed the leak in Bug 209932 by moving an early return, but Darin was curious about why this variable had never been converted:
Comment 1 Radar WebKit Bug Importer 2020-04-03 12:11:05 PDT
Comment 2 David Kilzer (:ddkilzer) 2020-04-03 12:12:30 PDT
Created attachment 395400 [details]
Patch v1
Comment 3 David Kilzer (:ddkilzer) 2020-04-03 12:13:18 PDT
LOL!  Commit r8412 is so old that Bugzilla refuses to link it!

Comment 4 Darin Adler 2020-04-03 12:18:34 PDT
Comment on attachment 395400 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=395400&action=review

> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:1258
> +        RetainPtr<NSMutableAttributedString> attrString = adoptNS([[NSMutableAttributedString alloc] init]);

Could just write:

    auto attrString = ...
Comment 5 David Kilzer (:ddkilzer) 2020-04-03 12:24:05 PDT
Created attachment 395401 [details]
Patch for landing
Comment 6 EWS 2020-04-03 12:50:48 PDT
Committed r259483: <https://trac.webkit.org/changeset/259483>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 395401 [details].