Title: [140892] trunk/Source/WebCore
Revision
140892
Author
[email protected]
Date
2013-01-25 17:38:05 -0800 (Fri, 25 Jan 2013)

Log Message

Keep a RefPtr<SerializedScriptValue*> when we call serialize()/deserialize() in code generators
https://bugs.webkit.org/show_bug.cgi?id=107902

Reviewed by Abhishek Arya.

If you use a raw SerializedScriptValue* for serialize()/deserialize(),
it can potentially cause a use-after-free. This is because serialize()/
deserialize() can destruct a RefPtr of the SerializedScriptValue*,
depending on data that is serialized/deserialized. So we should keep a
RefPtr<SerializedScriptValue*> when we call serialize()/deserialize().
(See https://bugs.webkit.org/show_bug.cgi?id=107792 for more details.)

No tests. This is just a just-in-case fix.

* Modules/intents/Intent.h:
(WebCore::Intent::data):
* Modules/intents/IntentRequest.cpp:
(WebCore::IntentRequest::postResult):
(WebCore::IntentRequest::postFailure):
* Modules/intents/IntentRequest.h:
(IntentRequest):
* Modules/intents/IntentResultCallback.h:
(IntentResultCallback):
* bindings/scripts/CodeGeneratorJS.pm:
(GetNativeTypeForCallbacks):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
(GetNativeTypeForCallbacks):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
(WebCore::TestSerializedScriptValueInterfaceV8Internal::cachedValueAttrGetter):
(WebCore::TestSerializedScriptValueInterfaceV8Internal::cachedReadonlyValueAttrGetter):
* dom/MessagePortChannel.h:
(WebCore::MessagePortChannel::EventData::message):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140891 => 140892)


--- trunk/Source/WebCore/ChangeLog	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/ChangeLog	2013-01-26 01:38:05 UTC (rev 140892)
@@ -1,5 +1,41 @@
 2013-01-25  Kentaro Hara  <[email protected]>
 
+        Keep a RefPtr<SerializedScriptValue*> when we call serialize()/deserialize() in code generators
+        https://bugs.webkit.org/show_bug.cgi?id=107902
+
+        Reviewed by Abhishek Arya.
+
+        If you use a raw SerializedScriptValue* for serialize()/deserialize(),
+        it can potentially cause a use-after-free. This is because serialize()/
+        deserialize() can destruct a RefPtr of the SerializedScriptValue*,
+        depending on data that is serialized/deserialized. So we should keep a
+        RefPtr<SerializedScriptValue*> when we call serialize()/deserialize().
+        (See https://bugs.webkit.org/show_bug.cgi?id=107792 for more details.)
+
+        No tests. This is just a just-in-case fix.
+
+        * Modules/intents/Intent.h:
+        (WebCore::Intent::data):
+        * Modules/intents/IntentRequest.cpp:
+        (WebCore::IntentRequest::postResult):
+        (WebCore::IntentRequest::postFailure):
+        * Modules/intents/IntentRequest.h:
+        (IntentRequest):
+        * Modules/intents/IntentResultCallback.h:
+        (IntentResultCallback):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetNativeTypeForCallbacks):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNormalAttrGetter):
+        (GetNativeTypeForCallbacks):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
+        (WebCore::TestSerializedScriptValueInterfaceV8Internal::cachedValueAttrGetter):
+        (WebCore::TestSerializedScriptValueInterfaceV8Internal::cachedReadonlyValueAttrGetter):
+        * dom/MessagePortChannel.h:
+        (WebCore::MessagePortChannel::EventData::message):
+
+2013-01-25  Kentaro Hara  <[email protected]>
+
         Keep a RefPtr<SerializedScriptValue*> when we call serialize()/deserialize() for MessageEvent
         https://bugs.webkit.org/show_bug.cgi?id=107900
 

Modified: trunk/Source/WebCore/Modules/intents/Intent.h (140891 => 140892)


--- trunk/Source/WebCore/Modules/intents/Intent.h	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/Modules/intents/Intent.h	2013-01-26 01:38:05 UTC (rev 140892)
@@ -36,6 +36,7 @@
 #include "MessagePort.h"
 #include "MessagePortChannel.h"
 #include "ScriptState.h"
+#include "SerializedScriptValue.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -45,8 +46,6 @@
 
 namespace WebCore {
 
-class SerializedScriptValue;
-
 typedef int ExceptionCode;
 
 class Intent : public RefCounted<Intent> {
@@ -58,7 +57,7 @@
 
     const String& action() const { return m_action; }
     const String& type() const { return m_type; }
-    SerializedScriptValue* data() const { return m_data.get(); }
+    PassRefPtr<SerializedScriptValue> data() const { return m_data; }
 
     MessagePortChannelArray* messagePorts() const { return m_ports.get(); }
     const KURL& service() const { return m_service; }

Modified: trunk/Source/WebCore/Modules/intents/IntentRequest.cpp (140891 => 140892)


--- trunk/Source/WebCore/Modules/intents/IntentRequest.cpp	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/Modules/intents/IntentRequest.cpp	2013-01-26 01:38:05 UTC (rev 140892)
@@ -69,7 +69,7 @@
     m_stopped = true;
 }
 
-void IntentRequest::postResult(SerializedScriptValue* data)
+void IntentRequest::postResult(PassRefPtr<SerializedScriptValue> data)
 {
     if (m_stopped)
         return;
@@ -86,7 +86,7 @@
     m_errorCallback.clear();
 }
 
-void IntentRequest::postFailure(SerializedScriptValue* data)
+void IntentRequest::postFailure(PassRefPtr<SerializedScriptValue> data)
 {
     if (m_stopped)
         return;

Modified: trunk/Source/WebCore/Modules/intents/IntentRequest.h (140891 => 140892)


--- trunk/Source/WebCore/Modules/intents/IntentRequest.h	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/Modules/intents/IntentRequest.h	2013-01-26 01:38:05 UTC (rev 140892)
@@ -47,8 +47,8 @@
 
     Intent* intent() { return m_intent.get(); }
 
-    void postResult(SerializedScriptValue*);
-    void postFailure(SerializedScriptValue*);
+    void postResult(PassRefPtr<SerializedScriptValue>);
+    void postFailure(PassRefPtr<SerializedScriptValue>);
 
     virtual void contextDestroyed() OVERRIDE;
 

Modified: trunk/Source/WebCore/Modules/intents/IntentResultCallback.h (140891 => 140892)


--- trunk/Source/WebCore/Modules/intents/IntentResultCallback.h	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/Modules/intents/IntentResultCallback.h	2013-01-26 01:38:05 UTC (rev 140892)
@@ -41,7 +41,7 @@
 class IntentResultCallback : public RefCounted<IntentResultCallback> {
 public:
     virtual ~IntentResultCallback() { }
-    virtual bool handleEvent(SerializedScriptValue* result) = 0;
+    virtual bool handleEvent(PassRefPtr<SerializedScriptValue> result) = 0;
 };
 
 }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (140891 => 140892)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-01-26 01:38:05 UTC (rev 140892)
@@ -3092,7 +3092,7 @@
 sub GetNativeTypeForCallbacks
 {
     my $type = shift;
-    return "SerializedScriptValue*" if $type eq "SerializedScriptValue";
+    return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
     return "PassRefPtr<DOMStringList>" if $type eq "DOMStringList";
 
     return GetNativeType($type);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (140891 => 140892)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-26 01:38:05 UTC (rev 140892)
@@ -1111,7 +1111,7 @@
     } elsif ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->{"CachedAttribute"}) {
         my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name);
         push(@implContentDecls, <<END);
-    SerializedScriptValue* serialized = imp->${getterFunc}();
+    RefPtr<SerializedScriptValue> serialized = imp->${getterFunc}();
     value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Null(info.GetIsolate()));
     info.Holder()->SetHiddenValue(propertyName, value);
     return value;
@@ -3748,7 +3748,7 @@
 {
     my $type = shift;
     return "const String&" if $type eq "DOMString";
-    return "SerializedScriptValue*" if $type eq "SerializedScriptValue";
+    return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
 
     # Callbacks use raw pointers, so pass isParameter = 1
     return GetNativeType($type, 1);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (140891 => 140892)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2013-01-26 01:38:05 UTC (rev 140892)
@@ -71,7 +71,7 @@
     if (!value.IsEmpty())
         return value;
     TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder());
-    SerializedScriptValue* serialized = imp->cachedValue();
+    RefPtr<SerializedScriptValue> serialized = imp->cachedValue();
     value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Null(info.GetIsolate()));
     info.Holder()->SetHiddenValue(propertyName, value);
     return value;
@@ -106,7 +106,7 @@
     if (!value.IsEmpty())
         return value;
     TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder());
-    SerializedScriptValue* serialized = imp->cachedReadonlyValue();
+    RefPtr<SerializedScriptValue> serialized = imp->cachedReadonlyValue();
     value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8Null(info.GetIsolate()));
     info.Holder()->SetHiddenValue(propertyName, value);
     return value;

Modified: trunk/Source/WebCore/dom/MessagePortChannel.h (140891 => 140892)


--- trunk/Source/WebCore/dom/MessagePortChannel.h	2013-01-26 01:36:40 UTC (rev 140891)
+++ trunk/Source/WebCore/dom/MessagePortChannel.h	2013-01-26 01:38:05 UTC (rev 140892)
@@ -82,7 +82,7 @@
         public:
             static PassOwnPtr<EventData> create(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
 
-            SerializedScriptValue* message() { return m_message.get(); }
+            PassRefPtr<SerializedScriptValue> message() { return m_message; }
             PassOwnPtr<MessagePortChannelArray> channels() { return m_channels.release(); }
 
         private:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to