Bug 1325158: Part 2 - Correctly handle extra OnRedirectVerifyCallback calls. draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 24 Dec 2016 18:25:18 -0800
changeset 454930 9bf78b40dca8e94fde9cfe7eb9f8e04c83c2dfaa
parent 454929 baa8c9f409da54c06cea5fac4dfa6462e2a06697
child 454931 331b667101d7a67b80db6812663d4232b8d557fc
push id40082
push usermaglione.k@gmail.com
push dateFri, 30 Dec 2016 19:18:45 +0000
bugs1325158
milestone53.0a1
Bug 1325158: Part 2 - Correctly handle extra OnRedirectVerifyCallback calls. MozReview-Commit-ID: Hl1C6ZEdZKF
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -101,16 +101,21 @@ nsAsyncRedirectVerifyHelper::Init(nsICha
 
 NS_IMETHODIMP
 nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback(nsresult result)
 {
     LOG(("nsAsyncRedirectVerifyHelper::OnRedirectVerifyCallback() "
          "result=%x expectedCBs=%u mResult=%x",
          result, mExpectedCallbacks, mResult));
 
+    if (mExpectedCallbacks <= 0) {
+      NS_ERROR("OnRedirectVerifyCallback called more times than expected");
+      return NS_ERROR_UNEXPECTED;
+    }
+
     --mExpectedCallbacks;
 
     // If response indicates failure we may call back immediately
     if (NS_FAILED(result)) {
         // We chose to store the first failure-value (as opposed to the last)
         if (NS_SUCCEEDED(mResult))
             mResult = result;