Bug 1036056 - Remove dangerous public destructor of nsFileUploadContentStream r=mcmanus
authorSteve Workman <sworkman@mozilla.com>
Wed, 09 Jul 2014 11:02:06 -0700
changeset 193103 beb201c2abbdd319c6bbd999ee43c0634742b219
parent 193102 3a4d57c7ffdf74dae7e1c3e1cdadba44750dab15
child 193104 7b5a6cc2a2447eb6e8331a069837ac69a5b360ce
push id46021
push usersworkman@mozilla.com
push dateWed, 09 Jul 2014 18:02:24 +0000
treeherdermozilla-inbound@beb201c2abbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1036056
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1036056 - Remove dangerous public destructor of nsFileUploadContentStream r=mcmanus
netwerk/protocol/file/nsFileChannel.cpp
--- a/netwerk/protocol/file/nsFileChannel.cpp
+++ b/netwerk/protocol/file/nsFileChannel.cpp
@@ -173,30 +173,24 @@ public:
   }
 
   NS_IMETHODIMP ReadSegments(nsWriteSegmentFun fun, void *closure,
                              uint32_t count, uint32_t *result);
   NS_IMETHODIMP AsyncWait(nsIInputStreamCallback *callback, uint32_t flags,
                           uint32_t count, nsIEventTarget *target);
 
 private:
+  virtual ~nsFileUploadContentStream() {}
+
   void OnCopyComplete();
 
   nsRefPtr<nsFileCopyEvent> mCopyEvent;
   nsCOMPtr<nsITransportEventSink> mSink;
 };
 
-namespace mozilla {
-template<>
-struct HasDangerousPublicDestructor<nsFileUploadContentStream>
-{
-  static const bool value = true;
-};
-}
-
 NS_IMPL_ISUPPORTS_INHERITED0(nsFileUploadContentStream,
                              nsBaseContentStream)
 
 NS_IMETHODIMP
 nsFileUploadContentStream::ReadSegments(nsWriteSegmentFun fun, void *closure,
                                         uint32_t count, uint32_t *result)
 {
   *result = 0;  // nothing is ever actually read from this stream
@@ -360,24 +354,23 @@ nsFileChannel::OpenContentStream(bool as
 
     nsCOMPtr<nsIOutputStream> fileStream;
     rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileStream), file,
                                      PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
                                      PR_IRUSR | PR_IWUSR);
     if (NS_FAILED(rv))
       return rv;
 
-    nsFileUploadContentStream *uploadStream =
+    nsRefPtr<nsFileUploadContentStream> uploadStream =
         new nsFileUploadContentStream(async, fileStream, mUploadStream,
                                       mUploadLength, this);
     if (!uploadStream || !uploadStream->IsInitialized()) {
-      delete uploadStream;
       return NS_ERROR_OUT_OF_MEMORY;
     }
-    stream = uploadStream;
+    stream = uploadStream.forget();
 
     mContentLength = 0;
 
     // Since there isn't any content to speak of we just set the content-type
     // to something other than "unknown" to avoid triggering the content-type
     // sniffer code in nsBaseChannel.
     // However, don't override explicitly set types.
     if (!HasContentTypeHint())