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 3270627..e6b0a52 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 9604737..407c6d0 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];