Crash when closing a page with a form field when using WebKit2.
authorjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Sep 2010 00:18:07 +0000 (00:18 +0000)
committerjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Sep 2010 00:18:07 +0000 (00:18 +0000)
Reviewed by Anders Carlsson.

The crash came from accessing a BundlePageFormClient that had been
destroyed. The client was intended to be cleared by a call to
WKBundlePageSetFormClient, but a null check there caused it not to be
cleared.

I fixed this and all of the other WK "set client" functions.

* UIProcess/API/C/WKContext.cpp:
(WKContextSetInjectedBundleClient):
Return early if the caller passed a client with a version not equal to
0.
(WKContextSetHistoryClient):
Ditto.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageLoaderClient):
Ditto.
(WKPageSetPagePolicyClient):
Ditto.
(WKPageSetPageFormClient):
Ditto.
(WKPageSetPageUIClient):
Ditto.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleSetClient):
Ditto.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetEditorClient):
Ditto.
(WKBundlePageSetFormClient):
Ditto.
(WKBundlePageSetLoaderClient):
Ditto.
(WKBundlePageSetUIClient):
Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66557 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/UIProcess/API/C/WKContext.cpp
WebKit2/UIProcess/API/C/WKPage.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

index c62dbf0..63c8c9d 100644 (file)
@@ -1,3 +1,47 @@
+2010-08-31  Jon Honeycutt  <jhoneycutt@apple.com>
+
+        Crash when closing a page with a form field when using WebKit2.
+
+        Reviewed by Anders Carlsson.
+
+        The crash came from accessing a BundlePageFormClient that had been
+        destroyed. The client was intended to be cleared by a call to
+        WKBundlePageSetFormClient, but a null check there caused it not to be
+        cleared.
+
+        I fixed this and all of the other WK "set client" functions.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetInjectedBundleClient):
+        Return early if the caller passed a client with a version not equal to
+        0.
+        (WKContextSetHistoryClient):
+        Ditto.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageLoaderClient):
+        Ditto.
+        (WKPageSetPagePolicyClient):
+        Ditto.
+        (WKPageSetPageFormClient):
+        Ditto.
+        (WKPageSetPageUIClient):
+        Ditto.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleSetClient):
+        Ditto.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageSetEditorClient):
+        Ditto.
+        (WKBundlePageSetFormClient):
+        Ditto.
+        (WKBundlePageSetLoaderClient):
+        Ditto.
+        (WKBundlePageSetUIClient):
+        Ditto.
+
 2010-08-31  Alexey Proskuryakov  <ap@apple.com>
 
         Build fix.
index 324e1b0..f19b3b1 100644 (file)
@@ -74,14 +74,16 @@ WKPreferencesRef WKContextGetPreferences(WKContextRef contextRef)
 
 void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(contextRef)->initializeInjectedBundleClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(contextRef)->initializeInjectedBundleClient(wkClient);
 }
 
 void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(contextRef)->initializeHistoryClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(contextRef)->initializeHistoryClient(wkClient);
 }
 
 void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
index ee21029..910075c 100644 (file)
@@ -155,26 +155,30 @@ void WKPageRestoreFromSessionState(WKPageRef pageRef, WKDataRef sessionStateData
 
 void WKPageSetPageLoaderClient(WKPageRef pageRef, const WKPageLoaderClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeLoaderClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeLoaderClient(wkClient);
 }
 
 void WKPageSetPagePolicyClient(WKPageRef pageRef, const WKPagePolicyClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializePolicyClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializePolicyClient(wkClient);
 }
 
 void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeFormClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeFormClient(wkClient);
 }
 
 void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient * wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeUIClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeUIClient(wkClient);
 }
 
 void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
index 8a5606f..25618a3 100644 (file)
@@ -39,8 +39,9 @@ WKTypeID WKBundleGetTypeID()
 
 void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClient * wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(bundleRef)->initializeClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(bundleRef)->initializeClient(wkClient);
 }
 
 void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
index 38a6973..ee43536 100644 (file)
@@ -39,26 +39,30 @@ WKTypeID WKBundlePageGetTypeID()
 
 void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeInjectedBundleEditorClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeInjectedBundleEditorClient(wkClient);
 }
 
 void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeInjectedBundleFormClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeInjectedBundleFormClient(wkClient);
 }
 
 void WKBundlePageSetLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeInjectedBundleLoaderClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeInjectedBundleLoaderClient(wkClient);
 }
 
 void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient)
 {
-    if (wkClient && !wkClient->version)
-        toWK(pageRef)->initializeInjectedBundleUIClient(wkClient);
+    if (wkClient && wkClient->version)
+        return;
+    toWK(pageRef)->initializeInjectedBundleUIClient(wkClient);
 }
 
 WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)