Bug 504170 nsAStreamCopier::Process can use sourceCondition, sinkCondition uninitialized if someone cancels the copy early
authortimeless@mozdev.org
Wed, 12 Aug 2009 11:49:52 +0200
changeset 31356 df76fbd4b076d69757e18185f433e6f25c7b8ea3
parent 31355 82a6b7f6a049e1dd8e577cd581af187581827083
child 31357 288a10ff331df40851ead44b04014b0946679baf
push id8512
push usertimeless@mozdev.org
push dateWed, 12 Aug 2009 07:46:30 +0000
treeherdermozilla-central@1b368a826f91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs504170
milestone1.9.2a2pre
Bug 504170 nsAStreamCopier::Process can use sourceCondition, sinkCondition uninitialized if someone cancels the copy early r=dougt
xpcom/io/nsStreamUtils.cpp
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -383,22 +383,27 @@ public:
                             mSink->Close();
                     }
                 }
                 mAsyncSink = nsnull;
                 mSink = nsnull;
 
                 // notify state complete...
                 if (mCallback) {
-                    nsresult status = sourceCondition;
-                    if (NS_SUCCEEDED(status))
-                        status = sinkCondition;
-                    if (status == NS_BASE_STREAM_CLOSED)
-                        status = NS_OK;
-                    mCallback(mClosure, canceled ? cancelStatus : status);
+                    nsresult status;
+                    if (!canceled) {
+                        status = sourceCondition;
+                        if (NS_SUCCEEDED(status))
+                            status = sinkCondition;
+                        if (status == NS_BASE_STREAM_CLOSED)
+                            status = NS_OK;
+                    } else {
+                        status = cancelStatus; 
+                    }
+                    mCallback(mClosure, status);
                 }
                 break;
             }
         }
     }
 
     nsresult Cancel(nsresult aReason)
     {