Title: [94713] branches/chromium/835/Source/WebKit/chromium/src
Revision
94713
Author
[email protected]
Date
2011-09-07 14:10:29 -0700 (Wed, 07 Sep 2011)

Log Message

Merge 94102 - [Chromium] Add null checks for document()->loader()
https://bugs.webkit.org/show_bug.cgi?id=67077

Reviewed by Nate Chapin.

Document::loader can return 0 for a number of reasons.  Call sites need
to null check the result, like we do for Document::frame.  I suspect
some of these are real crashes, along the lines of
http://trac.webkit.org/changeset/93692, but null checking this function
is just good practice.

* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
* src/WebSearchableFormData.cpp:
(HTMLNames::GetFormEncoding):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::pageEncoding):


[email protected]
Review URL: http://codereview.chromium.org/7782040

Modified Paths

Diff

Modified: branches/chromium/835/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (94712 => 94713)


--- branches/chromium/835/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2011-09-07 21:04:47 UTC (rev 94712)
+++ branches/chromium/835/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2011-09-07 21:10:29 UTC (rev 94713)
@@ -243,7 +243,8 @@
 
     // If it's not a link, an image, a media element, or an image/media link,
     // show a selection menu or a more generic page menu.
-    data.frameEncoding = selectedFrame->document()->loader()->writer()->encoding();
+    if (selectedFrame->document()->loader())
+        data.frameEncoding = selectedFrame->document()->loader()->writer()->encoding();
 
     // Send the frame and page URLs in any case.
     data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame());

Modified: branches/chromium/835/Source/WebKit/chromium/src/WebSearchableFormData.cpp (94712 => 94713)


--- branches/chromium/835/Source/WebKit/chromium/src/WebSearchableFormData.cpp	2011-09-07 21:04:47 UTC (rev 94712)
+++ branches/chromium/835/Source/WebKit/chromium/src/WebSearchableFormData.cpp	2011-09-07 21:10:29 UTC (rev 94713)
@@ -64,6 +64,8 @@
         if (encoding->isValid())
             return;
     }
+    if (!form->document()->loader())
+         return;
     *encoding = TextEncoding(form->document()->loader()->writer()->encoding());
 }
 

Modified: branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp (94712 => 94713)


--- branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-09-07 21:04:47 UTC (rev 94712)
+++ branches/chromium/835/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-09-07 21:10:29 UTC (rev 94713)
@@ -1628,6 +1628,9 @@
     if (!m_page.get())
         return WebString();
 
+    if (!m_page->mainFrame()->document()->loader())
+        return WebString();
+
     return m_page->mainFrame()->document()->loader()->writer()->encoding();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to