Bug 134038

Summary: -[JSContext setName:] leaks NSString
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: JavaScriptCoreAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, joepeck, mhahnenberg, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1 none

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.