Reviewed by Oliver.
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 21:05:33 +0000 (21:05 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 21:05:33 +0000 (21:05 +0000)
        <rdar://problem/5636742>
        CrashTracer: [USER] 1302 crashes in Safari at com.apple.WebCore: WTF::Vector<char, 0ul>::reserveCapacity + 78

        When loading full-frame plug-ins, disable buffering data for the main resource loader. Otherwise, this can cause us
        to crash when loading large files such as movies in the browser. We already do this for embedded plug-ins.

        * WebCore.base.exp:
        * loader/DocumentLoader.h:
        (WebCore::DocumentLoader::mainResourceLoader):
        New accessor method.

        * loader/PluginDocument.cpp:
        (WebCore::PluginTokenizer::writeRawData):
        Disable buffering for the main resource loader.

        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::setShouldBufferData):
        * loader/ResourceLoader.h:
        Have this free the buffer when disabling buffering.

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

WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/loader/DocumentLoader.h
WebCore/loader/PluginDocument.cpp
WebCore/loader/ResourceLoader.cpp
WebCore/loader/ResourceLoader.h

index 6e1c76cdeaa5a79befa3b7fe91ccf0240c37b3d8..c9b54571c9a6f350e90e0a6c2020b3da6fc2b99d 100644 (file)
@@ -1,3 +1,27 @@
+2008-01-17  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Oliver.
+
+        <rdar://problem/5636742>
+        CrashTracer: [USER] 1302 crashes in Safari at com.apple.WebCore: WTF::Vector<char, 0ul>::reserveCapacity + 78
+        
+        When loading full-frame plug-ins, disable buffering data for the main resource loader. Otherwise, this can cause us
+        to crash when loading large files such as movies in the browser. We already do this for embedded plug-ins.
+        
+        * WebCore.base.exp:
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::mainResourceLoader):
+        New accessor method.
+        
+        * loader/PluginDocument.cpp:
+        (WebCore::PluginTokenizer::writeRawData):
+        Disable buffering for the main resource loader.
+        
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::setShouldBufferData):
+        * loader/ResourceLoader.h:
+        Have this free the buffer when disabling buffering.
+
 2008-01-17  Adam Roben  <aroben@apple.com>
 
         More Qt/GTK+ build fixing.
index 67b0e36e6a7dd545669ee540bd779b108dfa00d9..62548bbbe7ee334e57514621184017d781239495 100644 (file)
@@ -268,6 +268,7 @@ __ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
 __ZN7WebCore14DragController9dragEndedEv
 __ZN7WebCore14ResourceHandle12releaseProxyEv
 __ZN7WebCore14ResourceLoader14cancelledErrorEv
+__ZN7WebCore14ResourceLoader19setShouldBufferDataEb
 __ZN7WebCore14SecurityOrigin6createERKNS_6StringES3_tPS0_
 __ZN7WebCore15BackForwardList10removeItemEPNS_11HistoryItemE
 __ZN7WebCore15BackForwardList10setEnabledEb
index 58482d37e93c1f6e80419b503ea0cdbe9fe7379f..15303fe626fc836e33db405da721fafc3e5ec0a5 100644 (file)
@@ -68,6 +68,7 @@ namespace WebCore {
         virtual void detachFromFrame();
 
         FrameLoader* frameLoader() const;
+        MainResourceLoader* mainResourceLoader() const { return m_mainResourceLoader.get(); }
         PassRefPtr<SharedBuffer> mainResourceData() const;
 
         const ResourceRequest& originalRequest() const;
index ea58c891e10730178247d9b0ec2739b593cb6ee1..492c0f675923d2fb79454b968fad62e8252a9722 100644 (file)
 #include "config.h"
 #include "PluginDocument.h"
 
+#include "DocumentLoader.h"
+#include "Element.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
-#include "Element.h"
+#include "HTMLEmbedElement.h"
 #include "HTMLNames.h"
+#include "MainResourceLoader.h"
 #include "Page.h"
 #include "RenderWidget.h"
 #include "SegmentedString.h"
 #include "Settings.h"
 #include "Text.h"
-#include "HTMLEmbedElement.h"
 #include "XMLTokenizer.h"
 
 namespace WebCore {
@@ -102,8 +104,10 @@ bool PluginTokenizer::writeRawData(const char* data, int len)
             if (settings && settings->arePluginsEnabled()) {
                 m_doc->updateLayout();
             
-                if (RenderWidget* renderer = static_cast<RenderWidget*>(m_embedElement->renderer()))
+                if (RenderWidget* renderer = static_cast<RenderWidget*>(m_embedElement->renderer())) {
                     frame->loader()->client()->redirectDataToPlugin(renderer->widget());
+                    frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
+                }
             
                 finish();
             }
index 088cecdf3e11d862bac6e0b1a763c27673668892..ea96e34678c2a06b7588bfcba8ee23fcd278a994 100644 (file)
@@ -149,6 +149,16 @@ FrameLoader* ResourceLoader::frameLoader() const
     return m_frame->loader();
 }
 
+void ResourceLoader::setShouldBufferData(bool shouldBufferData)
+{ 
+    m_shouldBufferData = shouldBufferData; 
+
+    // Reset any already buffered data
+    if (!m_shouldBufferData)
+        m_resourceData = 0;
+}
+    
+
 void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
 {
     if (!m_shouldBufferData)
index 87cd239b529a59b844ca2979c36f05401715a5ca..3f1784f669f846a2c87d7c371fe446599419a151 100644 (file)
@@ -105,7 +105,7 @@ namespace WebCore {
         ResourceHandle* handle() const { return m_handle.get(); }
         bool sendResourceLoadCallbacks() const { return m_sendResourceLoadCallbacks; }
 
-        void setShouldBufferData(bool shouldBufferData) { m_shouldBufferData = shouldBufferData; }
+        void setShouldBufferData(bool shouldBufferData);
 
     protected:
         ResourceLoader(Frame*, bool sendResourceLoadCallbacks, bool shouldContentSniff);