Bug 134038 - -[JSContext setName:] leaks NSString
Summary: -[JSContext setName:] leaks NSString
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-18 13:51 PDT by David Kilzer (:ddkilzer)
Modified: 2014-06-19 20:39 PDT (History)
5 users (show)

See Also:


Attachments
Patch v1 (1.66 KB, patch)
2014-06-18 13:53 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) 2014-06-18 13:51:55 PDT
JavaScriptCore/API/JSContext.mm:200:73: warning: Potential leak of an object
    JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;
                                                                        ^
Comment 1 David Kilzer (:ddkilzer) 2014-06-18 13:53:28 PDT
Created attachment 233325 [details]
Patch v1
Comment 2 Joseph Pecoraro 2014-06-18 14:05:29 PDT
Comment on attachment 233325 [details]
Patch v1

r=me! Thanks
Comment 3 WebKit Commit Bot 2014-06-18 14:42:13 PDT
Comment on attachment 233325 [details]
Patch v1

Clearing flags on attachment: 233325

Committed r170117: <http://trac.webkit.org/changeset/170117>
Comment 4 WebKit Commit Bot 2014-06-18 14:42:15 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Darin Adler 2014-06-19 20:39:18 PDT
Comment on attachment 233325 [details]
Patch v1

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

> Source/JavaScriptCore/API/JSContext.mm:200
> -    JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;
> +    JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[[name copy] autorelease]) : nullptr;

Why not just remove the call to copy? There’s no need for a copy here.