Bug 1486690 - Remove unnecessary checks after moz_xrealloc() calls. r=glandium
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 28 Aug 2018 15:56:23 +1000
changeset 491485 c330fb64bcd0eb4e8ef98c0389dbd1df19b62b96
parent 491484 8afde49af9c1f5a04c3611d6ef6de53ac98f0d8d
child 491486 d6ccf1492e714566c84bb63de3fae0405cc465d9
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1486690
milestone63.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 1486690 - Remove unnecessary checks after moz_xrealloc() calls. r=glandium
netwerk/cache/nsCacheEntryDescriptor.cpp
security/manager/ssl/nsNSSASN1Object.cpp
xpcom/io/nsSegmentedBuffer.cpp
--- a/netwerk/cache/nsCacheEntryDescriptor.cpp
+++ b/netwerk/cache/nsCacheEntryDescriptor.cpp
@@ -916,23 +916,18 @@ nsDecompressInputStreamWrapper::Read(cha
 
     if (mReadBufferLen < count) {
         // Allocate a buffer for reading from the input stream. This will
         // determine the max number of compressed bytes read from the
         // input stream at one time. Making the buffer size proportional
         // to the request size is not necessary, but helps minimize the
         // number of read requests to the input stream.
         uint32_t newBufLen = std::max(count, (uint32_t)kMinDecompressReadBufLen);
-        unsigned char* newBuf;
-        newBuf = (unsigned char*)moz_xrealloc(mReadBuffer,
-            newBufLen);
-        if (newBuf) {
-            mReadBuffer = newBuf;
-            mReadBufferLen = newBufLen;
-        }
+        mReadBuffer = (unsigned char*)moz_xrealloc(mReadBuffer, newBufLen);
+        mReadBufferLen = newBufLen;
         if (!mReadBuffer) {
             mReadBufferLen = 0;
             return NS_ERROR_OUT_OF_MEMORY;
         }
     }
 
     // read and inflate data until the output buffer is full, or
     // there is no more data to read
--- a/security/manager/ssl/nsNSSASN1Object.cpp
+++ b/security/manager/ssl/nsNSSASN1Object.cpp
@@ -381,21 +381,17 @@ nsNSSASN1PrintableItem::SetType(uint32_t
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNSSASN1PrintableItem::SetData(char *data, uint32_t len)
 {
   if (len > 0) {
     if (mLen < len) {
-      unsigned char* newData = (unsigned char*)moz_xrealloc(mData, len);
-      if (!newData)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-      mData = newData;
+      mData = (unsigned char*)moz_xrealloc(mData, len);
     }
 
     memcpy(mData, data, len);
   } else if (len == 0) {
     if (mData) {
       free(mData);
       mData = nullptr;
     }
--- a/xpcom/io/nsSegmentedBuffer.cpp
+++ b/xpcom/io/nsSegmentedBuffer.cpp
@@ -34,21 +34,17 @@ nsSegmentedBuffer::AppendNewSegment()
     uint32_t bytes = mSegmentArrayCount * sizeof(char*);
     mSegmentArray = (char**)moz_xmalloc(bytes);
     memset(mSegmentArray, 0, bytes);
   }
 
   if (IsFull()) {
     uint32_t newArraySize = mSegmentArrayCount * 2;
     uint32_t bytes = newArraySize * sizeof(char*);
-    char** newSegArray = (char**)moz_xrealloc(mSegmentArray, bytes);
-    if (!newSegArray) {
-      return nullptr;
-    }
-    mSegmentArray = newSegArray;
+    mSegmentArray = (char**)moz_xrealloc(mSegmentArray, bytes);
     // copy wrapped content to new extension
     if (mFirstSegmentIndex > mLastSegmentIndex) {
       // deal with wrap around case
       memcpy(&mSegmentArray[mSegmentArrayCount],
              mSegmentArray,
              mLastSegmentIndex * sizeof(char*));
       memset(mSegmentArray, 0, mLastSegmentIndex * sizeof(char*));
       mLastSegmentIndex += mSegmentArrayCount;