Backed out changeset b6ac18409d64 (bug 1170809) for Werror bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 21 Jun 2015 08:31:02 -0400
changeset 249930 577434cfbe6f8a401534dd076e63054073185206
parent 249929 b6ac18409d647b49f4caa1f78174944f4283c470
child 249931 190f21cd3194ba1c65426b08f9a600704ec177b3
push idunknown
push userunknown
push dateunknown
bugs1170809
milestone41.0a1
backs outb6ac18409d647b49f4caa1f78174944f4283c470
Backed out changeset b6ac18409d64 (bug 1170809) for Werror bustage.
dom/base/nsXMLHttpRequest.cpp
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -673,45 +673,38 @@ nsXMLHttpRequest::AppendToResponseText(c
 {
   NS_ENSURE_STATE(mDecoder);
 
   int32_t destBufferLen;
   nsresult rv = mDecoder->GetMaxLength(aSrcBuffer, aSrcBufferLen,
                                        &destBufferLen);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  uint32_t size = mResponseText.Length() + destBufferLen;
-  if (size < destBufferLen) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  if (!mResponseText.SetCapacity(size, 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).
   int32_t srclen = (int32_t)aSrcBufferLen;
   int32_t destlen = (int32_t)destBufferLen;
   rv = mDecoder->Convert(aSrcBuffer,
                          &srclen,
                          destBuffer,
                          &destlen);
   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;
 }
 
 /* readonly attribute AString responseText; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
 {
   ErrorResult rv;