Title: [150980] branches/safari-537.43-branch/Source/_javascript_Core

Diff

Modified: branches/safari-537.43-branch/Source/_javascript_Core/API/JSValue.mm (150979 => 150980)


--- branches/safari-537.43-branch/Source/_javascript_Core/API/JSValue.mm	2013-05-30 20:53:15 UTC (rev 150979)
+++ branches/safari-537.43-branch/Source/_javascript_Core/API/JSValue.mm	2013-05-30 20:55:18 UTC (rev 150980)
@@ -971,6 +971,7 @@
 
     _context = [context retain];
     m_value = value;
+    JSValueProtect([_context JSGlobalContextRef], m_value);
     return self;
 }
 
@@ -1088,6 +1089,7 @@
 
 - (void)dealloc
 {
+    JSValueUnprotect([_context JSGlobalContextRef], m_value);
     [_context release];
     _context = nil;
     [super dealloc];

Modified: branches/safari-537.43-branch/Source/_javascript_Core/API/tests/testapi.mm (150979 => 150980)


--- branches/safari-537.43-branch/Source/_javascript_Core/API/tests/testapi.mm	2013-05-30 20:53:15 UTC (rev 150979)
+++ branches/safari-537.43-branch/Source/_javascript_Core/API/tests/testapi.mm	2013-05-30 20:55:18 UTC (rev 150980)
@@ -802,6 +802,15 @@
 
         [TinyDOMNode clearSharedVirtualMachine];
     }
+
+    @autoreleasepool {
+        JSContext *context = [[JSContext alloc] init];
+        JSValue *o = [JSValue valueWithNewObjectInContext:context];
+        o[@"foo"] = @"foo";
+        JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
+
+        checkResult(@"JSValue correctly protected its internal value", [[o[@"foo"] toString] isEqualToString:@"foo"]);
+    }
 }
 
 #else

Modified: branches/safari-537.43-branch/Source/_javascript_Core/ChangeLog (150979 => 150980)


--- branches/safari-537.43-branch/Source/_javascript_Core/ChangeLog	2013-05-30 20:53:15 UTC (rev 150979)
+++ branches/safari-537.43-branch/Source/_javascript_Core/ChangeLog	2013-05-30 20:55:18 UTC (rev 150980)
@@ -1,3 +1,22 @@
+2013-05-30  Lucas Forschler  <[email protected]>
+
+        Merge r150831
+
+    2013-05-28  Mark Hahnenberg  <[email protected]>
+
+            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.
+
 2013-05-28  Roger Fong  <[email protected]>
 
         Disable some feature flags.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to