Changeset 150831 in webkit


Ignore:
Timestamp:
May 28, 2013 2:18:44 PM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

r150199 is very wrong
https://bugs.webkit.org/show_bug.cgi?id=116876

JSValue needs to protect its internal JSValueRef.

Reviewed by Darin Adler.

  • API/JSValue.mm:

(-[JSValue initWithValue:inContext:]):
(-[JSValue dealloc]):

  • API/tests/testapi.mm: Added a simple test to make sure that we protect the

underlying JavaScript value across garbage collections.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

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

    r150199 r150831  
    972972    _context = [context retain];
    973973    m_value = value;
     974    JSValueProtect([_context JSGlobalContextRef], m_value);
    974975    return self;
    975976}
     
    10891090- (void)dealloc
    10901091{
     1092    JSValueUnprotect([_context JSGlobalContextRef], m_value);
    10911093    [_context release];
    10921094    _context = nil;
  • trunk/Source/JavaScriptCore/API/tests/testapi.mm

    r149401 r150831  
    803803        [TinyDOMNode clearSharedVirtualMachine];
    804804    }
     805
     806    @autoreleasepool {
     807        JSContext *context = [[JSContext alloc] init];
     808        JSValue *o = [JSValue valueWithNewObjectInContext:context];
     809        o[@"foo"] = @"foo";
     810        JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
     811
     812        checkResult(@"JSValue correctly protected its internal value", [[o[@"foo"] toString] isEqualToString:@"foo"]);
     813    }
    805814}
    806815
  • trunk/Source/JavaScriptCore/ChangeLog

    r150767 r150831  
     12013-05-28  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        r150199 is very wrong
     4        https://bugs.webkit.org/show_bug.cgi?id=116876
     5
     6        JSValue needs to protect its internal JSValueRef.
     7
     8        Reviewed by Darin Adler.
     9
     10        * API/JSValue.mm:
     11        (-[JSValue initWithValue:inContext:]):
     12        (-[JSValue dealloc]):
     13        * API/tests/testapi.mm: Added a simple test to make sure that we protect the
     14        underlying JavaScript value across garbage collections.
     15
    1162013-05-27  Patrick Gansterer  <paroga@webkit.org>
    217
Note: See TracChangeset for help on using the changeset viewer.