diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index 65b6b37785d..2912ff4fd62 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -678,20 +678,13 @@ nsXMLHttpRequest::AppendToResponseText(const char * aSrcBuffer, &destBufferLen); NS_ENSURE_SUCCESS(rv, rv); - CheckedInt32 neededCapacity = destBufferLen; - neededCapacity += mResponseText.Length(); - - if (!neededCapacity.isValid()) { - return NS_ERROR_OUT_OF_MEMORY; - } - - if (!mResponseText.SetCapacity(neededCapacity.value(), fallible)) { + if (!mResponseText.SetCapacity(mResponseText.Length() + destBufferLen, fallible)) { return NS_ERROR_OUT_OF_MEMORY; } char16_t* destBuffer = mResponseText.BeginWriting() + mResponseText.Length(); - CheckedInt32 totalChars = mResponseText.Length(); + int32_t totalChars = mResponseText.Length(); // This code here is basically a copy of a similar thing in // nsScanner::Append(const char* aBuffer, uint32_t aLen). @@ -704,11 +697,9 @@ nsXMLHttpRequest::AppendToResponseText(const char * aSrcBuffer, MOZ_ASSERT(NS_SUCCEEDED(rv)); totalChars += destlen; - if (!totalChars.isValid()) { - return NS_ERROR_OUT_OF_MEMORY; - } - mResponseText.SetLength(totalChars.value()); + mResponseText.SetLength(totalChars); + return NS_OK; }