Changeset 170117 in webkit


Ignore:
Timestamp:
Jun 18, 2014 2:41:44 PM (10 years ago)
Author:
ddkilzer@apple.com
Message:

-[JSContext setName:] leaks NSString
<http://webkit.org/b/134038>

Reviewed by Joseph Pecoraro.

Fixes the following static analyzer warning:

JavaScriptCore/API/JSContext.mm:200:73: warning: Potential leak of an object

JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;


  • API/JSContext.mm:

(-[JSContext setName:]): Autorelease the copy of |name|.

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSContext.mm

    r166756 r170117  
    198198- (void)setName:(NSString *)name
    199199{
    200     JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;
     200    JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[[name copy] autorelease]) : nullptr;
    201201    JSGlobalContextSetName(m_context, nameJS);
    202202    if (nameJS)
  • trunk/Source/JavaScriptCore/ChangeLog

    r170109 r170117  
     12014-06-18  David Kilzer  <ddkilzer@apple.com>
     2
     3        -[JSContext setName:] leaks NSString
     4        <http://webkit.org/b/134038>
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Fixes the following static analyzer warning:
     9
     10            JavaScriptCore/API/JSContext.mm:200:73: warning: Potential leak of an object
     11                JSStringRef nameJS = name ? JSStringCreateWithCFString((CFStringRef)[name copy]) : nullptr;
     12                                                                                    ^
     13
     14        * API/JSContext.mm:
     15        (-[JSContext setName:]): Autorelease the copy of |name|.
     16
    1172014-06-18  Mark Lam  <mark.lam@apple.com>
    218
Note: See TracChangeset for help on using the changeset viewer.