Fix an assertion failure seen on the layout tests, and when closing the window after...
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 09:05:32 +0000 (09:05 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 09:05:32 +0000 (09:05 +0000)
Reviewed by Oliver Hunt.

* Plugins/WebBaseNetscapePluginStream.mm:
(-[WebBaseNetscapePluginStream _destroyStream]): Unlink the file and close the file
descriptor even when the stream is being destroyed without the load completing. This
avoids leaking the path and file descriptor, and leaving the temporary file on disk.

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

WebKit/mac/ChangeLog
WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm

index 3270627e5cf06712b9a16473beea15e47afa04c2..e6b0a52274609432d3fcd61e9ada31ee369a9b2c 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-29  Mark Rowe  <mrowe@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Fix an assertion failure seen on the layout tests, and when closing the window after
+        visiting <http://www.coudal.com/losalamos/>.
+
+        * Plugins/WebBaseNetscapePluginStream.mm:
+        (-[WebBaseNetscapePluginStream _destroyStream]): Unlink the file and close the file
+        descriptor even when the stream is being destroyed without the load completing. This
+        avoids leaking the path and file descriptor, and leaving the temporary file on disk.
+
 2007-11-28  Adele Peterson  <adele@apple.com>
 
         Reviewed by Darin.
index 96047373b5043a820b548a1759cbd7db427c21a8..407c6d01d51de6705fec37f29f833828c6c1fdc8 100644 (file)
@@ -377,7 +377,10 @@ static StreamMap& streams()
             [pv willCallPlugInFunction];
             NPP_StreamAsFile(plugin, &stream, [carbonPath fileSystemRepresentation]);
             [pv didCallPlugInFunction];
+            LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", responseURL, carbonPath);
+        }
 
+        if (path) {
             // Delete the file after calling NPP_StreamAsFile(), instead of in -dealloc/-finalize.  It should be OK
             // to delete the file here -- NPP_StreamAsFile() is always called immediately before NPP_DestroyStream()
             // (the stream destruction function), so there can be no expectation that a plugin will read the stream
@@ -385,12 +388,17 @@ static StreamMap& streams()
             unlink([path fileSystemRepresentation]);
             [path release];
             path = nil;
-            LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", responseURL, carbonPath);
 
             if (isTerminated)
                 goto exit;
         }
 
+        if (fileDescriptor != -1) {
+            // The file may still be open if we are destroying the stream before it completed loading.
+            close(fileDescriptor);
+            fileDescriptor = -1;
+        }
+
         NPError npErr;
         WebBaseNetscapePluginView *pv = pluginView;
         [pv willCallPlugInFunction];