Bug 1122740 - remove useless null checks after allocating memory with |new| r=erahm
authorNicklas Boman <smurfd@gmail.com>
Tue, 04 Jun 2019 04:43:11 +0000
changeset 476725 39063905a5b8abcdf9e22efe94855621f69906f1
parent 476724 80b9b4eb8305f9dcaa35f0a355fbe673712e854d
child 476726 c1170685b543aeb8d1a5407838ca0d3a0e50b263
push id113311
push userbtara@mozilla.com
push dateTue, 04 Jun 2019 16:10:59 +0000
treeherdermozilla-inbound@10b68c24fc3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1122740
milestone69.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 1122740 - remove useless null checks after allocating memory with |new| r=erahm Differential Revision: https://phabricator.services.mozilla.com/D33445
xpcom/base/nsAgg.h
xpcom/base/nsInterfaceRequestorAgg.cpp
xpcom/components/nsCategoryManager.cpp
xpcom/ds/nsEnumeratorUtils.cpp
xpcom/ds/nsINIParserImpl.cpp
xpcom/ds/nsObserverService.cpp
xpcom/ds/nsStringEnumerator.cpp
xpcom/ds/nsVariant.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_alpha_openbsd.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_arm_openbsd.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_ipf32.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_ipf64.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_pa32.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_ppc64_linux.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_linux.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_openbsd.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_sparc64_openbsd.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_sparc_openbsd.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_darwin.cpp
xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp
xpcom/tests/gtest/TestPipes.cpp
xpcom/tests/windows/TestCOM.cpp
--- a/xpcom/base/nsAgg.h
+++ b/xpcom/base/nsAgg.h
@@ -278,38 +278,30 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAggregat
 #define NS_GENERIC_AGGREGATED_CONSTRUCTOR(_InstanceClass)                      \
   static nsresult _InstanceClass##Constructor(nsISupports* aOuter,             \
                                               REFNSIID aIID, void** aResult) { \
     *aResult = nullptr;                                                        \
     if (NS_WARN_IF(aOuter && !aIID.Equals(NS_GET_IID(nsISupports))))           \
       return NS_ERROR_INVALID_ARG;                                             \
                                                                                \
     RefPtr<_InstanceClass> inst = new _InstanceClass(aOuter);                  \
-    if (!inst) {                                                               \
-      return NS_ERROR_OUT_OF_MEMORY;                                           \
-    }                                                                          \
-                                                                               \
     nsISupports* inner = inst->InnerObject();                                  \
     nsresult rv = inner->QueryInterface(aIID, aResult);                        \
                                                                                \
     return rv;                                                                 \
   }
 
 #define NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(_InstanceClass, _InitMethod)    \
   static nsresult _InstanceClass##Constructor(nsISupports* aOuter,             \
                                               REFNSIID aIID, void** aResult) { \
     *aResult = nullptr;                                                        \
     if (NS_WARN_IF(aOuter && !aIID.Equals(NS_GET_IID(nsISupports))))           \
       return NS_ERROR_INVALID_ARG;                                             \
                                                                                \
     RefPtr<_InstanceClass> inst = new _InstanceClass(aOuter);                  \
-    if (!inst) {                                                               \
-      return NS_ERROR_OUT_OF_MEMORY;                                           \
-    }                                                                          \
-                                                                               \
     nsISupports* inner = inst->InnerObject();                                  \
     NS_ADDREF(inner);                                                          \
     nsresult rv = inst->_InitMethod();                                         \
     if (NS_SUCCEEDED(rv)) {                                                    \
       rv = inner->QueryInterface(aIID, aResult);                               \
     }                                                                          \
     NS_RELEASE(inner);                                                         \
                                                                                \
--- a/xpcom/base/nsInterfaceRequestorAgg.cpp
+++ b/xpcom/base/nsInterfaceRequestorAgg.cpp
@@ -53,26 +53,22 @@ nsInterfaceRequestorAgg::~nsInterfaceReq
   NS_ProxyRelease("nsInterfaceRequestorAgg::mSecond", mConsumerTarget,
                   mSecond.forget());
 }
 
 nsresult NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
                                              nsIInterfaceRequestor* aSecond,
                                              nsIInterfaceRequestor** aResult) {
   *aResult = new nsInterfaceRequestorAgg(aFirst, aSecond);
-  if (!*aResult) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+
   NS_ADDREF(*aResult);
   return NS_OK;
 }
 
 nsresult NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
                                              nsIInterfaceRequestor* aSecond,
                                              nsIEventTarget* aTarget,
                                              nsIInterfaceRequestor** aResult) {
   *aResult = new nsInterfaceRequestorAgg(aFirst, aSecond, aTarget);
-  if (!*aResult) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+
   NS_ADDREF(*aResult);
   return NS_OK;
 }
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -92,19 +92,16 @@ CategoryEnumerator::HasMoreElements(bool
 
 NS_IMETHODIMP
 CategoryEnumerator::GetNext(nsISupports** aResult) {
   if (mSimpleCurItem >= mCount) {
     return NS_ERROR_FAILURE;
   }
 
   auto* str = new nsSupportsDependentCString(mArray[mSimpleCurItem++]);
-  if (!str) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
 
   *aResult = str;
   NS_ADDREF(*aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CategoryEnumerator::HasMore(bool* aResult) {
--- a/xpcom/ds/nsEnumeratorUtils.cpp
+++ b/xpcom/ds/nsEnumeratorUtils.cpp
@@ -236,16 +236,13 @@ nsresult NS_NewUnionEnumerator(nsISimple
                                nsISimpleEnumerator* aSecondEnumerator) {
   *aResult = nullptr;
   if (!aFirstEnumerator) {
     *aResult = aSecondEnumerator;
   } else if (!aSecondEnumerator) {
     *aResult = aFirstEnumerator;
   } else {
     auto* enumer = new nsUnionEnumerator(aFirstEnumerator, aSecondEnumerator);
-    if (!enumer) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
     *aResult = enumer;
   }
   NS_ADDREF(*aResult);
   return NS_OK;
 }
--- a/xpcom/ds/nsINIParserImpl.cpp
+++ b/xpcom/ds/nsINIParserImpl.cpp
@@ -28,19 +28,16 @@ class nsINIParserImpl final : public nsI
 
 NS_IMPL_ISUPPORTS(nsINIParserFactory, nsIINIParserFactory, nsIFactory)
 
 NS_IMETHODIMP
 nsINIParserFactory::CreateINIParser(nsIFile* aINIFile, nsIINIParser** aResult) {
   *aResult = nullptr;
 
   RefPtr<nsINIParserImpl> p(new nsINIParserImpl());
-  if (!p) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
 
   if (aINIFile) {
     nsresult rv = p->Init(aINIFile);
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
@@ -72,19 +69,16 @@ static bool SectionCB(const char* aSecti
   nsTArray<nsCString>* strings = static_cast<nsTArray<nsCString>*>(aClosure);
   strings->AppendElement()->Assign(aSection);
   return true;
 }
 
 NS_IMETHODIMP
 nsINIParserImpl::GetSections(nsIUTF8StringEnumerator** aResult) {
   nsTArray<nsCString>* strings = new nsTArray<nsCString>;
-  if (!strings) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
 
   nsresult rv = mParser.GetSections(SectionCB, strings);
   if (NS_SUCCEEDED(rv)) {
     rv = NS_NewAdoptingUTF8StringEnumerator(aResult, strings);
   }
 
   if (NS_FAILED(rv)) {
     delete strings;
@@ -102,19 +96,16 @@ static bool KeyCB(const char* aKey, cons
 NS_IMETHODIMP
 nsINIParserImpl::GetKeys(const nsACString& aSection,
                          nsIUTF8StringEnumerator** aResult) {
   if (ContainsNull(aSection)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsTArray<nsCString>* strings = new nsTArray<nsCString>;
-  if (!strings) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
 
   nsresult rv =
       mParser.GetStrings(PromiseFlatCString(aSection).get(), KeyCB, strings);
   if (NS_SUCCEEDED(rv)) {
     rv = NS_NewAdoptingUTF8StringEnumerator(aResult, strings);
   }
 
   if (NS_FAILED(rv)) {
--- a/xpcom/ds/nsObserverService.cpp
+++ b/xpcom/ds/nsObserverService.cpp
@@ -149,20 +149,16 @@ void nsObserverService::Shutdown() {
 }
 
 nsresult nsObserverService::Create(nsISupports* aOuter, const nsIID& aIID,
                                    void** aInstancePtr) {
   LOG(("nsObserverService::Create()"));
 
   RefPtr<nsObserverService> os = new nsObserverService();
 
-  if (!os) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   // The memory reporter can not be immediately registered here because
   // the nsMemoryReporterManager may attempt to get the nsObserverService
   // during initialization, causing a recursive GetService.
   NS_DispatchToCurrentThread(
       NewRunnableMethod("nsObserverService::RegisterReporter", os,
                         &nsObserverService::RegisterReporter));
 
   return os->QueryInterface(aIID, aInstancePtr);
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -179,27 +179,21 @@ nsStringEnumerator::HasMoreElements(bool
 NS_IMETHODIMP
 nsStringEnumerator::GetNext(nsISupports** aResult) {
   if (mIndex >= mArray->Length()) {
     return NS_ERROR_FAILURE;
   }
 
   if (mIsUnicode) {
     nsSupportsString* stringImpl = new nsSupportsString();
-    if (!stringImpl) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
 
     stringImpl->SetData(mArray->ElementAt(mIndex++));
     *aResult = stringImpl;
   } else {
     nsSupportsCString* cstringImpl = new nsSupportsCString();
-    if (!cstringImpl) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
 
     cstringImpl->SetData(mCArray->ElementAt(mIndex++));
     *aResult = cstringImpl;
   }
   NS_ADDREF(*aResult);
   return NS_OK;
 }
 
--- a/xpcom/ds/nsVariant.cpp
+++ b/xpcom/ds/nsVariant.cpp
@@ -1156,43 +1156,37 @@ nsresult nsDiscriminatedUnion::SetFromVa
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_WCHAR, mWCharValue, WChar)
     CASE__SET_FROM_VARIANT_TYPE(VTYPE_ID, mIDValue, ID)
 
     case nsIDataType::VTYPE_ASTRING:
     case nsIDataType::VTYPE_WCHAR_STR:
     case nsIDataType::VTYPE_WSTRING_SIZE_IS:
       CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(VTYPE_ASTRING);
       u.mAStringValue = new nsString();
-      if (!u.mAStringValue) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+
       rv = aValue->GetAsAString(*u.mAStringValue);
       if (NS_FAILED(rv)) {
         delete u.mAStringValue;
       }
       CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(VTYPE_ASTRING)
 
     case nsIDataType::VTYPE_CSTRING:
       CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(VTYPE_CSTRING);
       u.mCStringValue = new nsCString();
-      if (!u.mCStringValue) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+
       rv = aValue->GetAsACString(*u.mCStringValue);
       if (NS_FAILED(rv)) {
         delete u.mCStringValue;
       }
       CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(VTYPE_CSTRING)
 
     case nsIDataType::VTYPE_UTF8STRING:
       CASE__SET_FROM_VARIANT_VTYPE_PROLOGUE(VTYPE_UTF8STRING);
       u.mUTF8StringValue = new nsUTF8String();
-      if (!u.mUTF8StringValue) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+
       rv = aValue->GetAsAUTF8String(*u.mUTF8StringValue);
       if (NS_FAILED(rv)) {
         delete u.mUTF8StringValue;
       }
       CASE__SET_FROM_VARIANT_VTYPE_EPILOGUE(VTYPE_UTF8STRING)
 
     case nsIDataType::VTYPE_CHAR_STR:
     case nsIDataType::VTYPE_STRING_SIZE_IS:
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_alpha_openbsd.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_alpha_openbsd.cpp
@@ -32,18 +32,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     // args[0] to args[NUM_ARG_REGS] hold floating point register values
     uint64_t* ap = args + NUM_ARG_REGS;
     for(i = 0; i < paramCount; i++, ap++)
     {
         const nsXPTParamInfo& param = info->GetParam(i);
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_arm_openbsd.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_arm_openbsd.cpp
@@ -41,18 +41,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint32_t* ap = args;
     for(i = 0; i < paramCount; i++, ap++)
     {
         const nsXPTParamInfo& param = info->GetParam(i);
         const nsXPTType& type = param.GetType();
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_ipf32.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_ipf32.cpp
@@ -38,18 +38,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
   paramCount = info->GetParamCount();
 
   // setup variant array pointer
   if(paramCount > PARAM_BUFFER_COUNT)
     dispatchParams = new nsXPTCMiniVariant[paramCount];
   else
     dispatchParams = paramBuffer;
   NS_ASSERTION(dispatchParams,"no place for params");
-  if (! dispatchParams)
-      return NS_ERROR_OUT_OF_MEMORY;
 
   const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
   for(i = 0; i < paramCount; ++i)
   {
     int isfloat = 0;
     const nsXPTParamInfo& param = info->GetParam(i);
     const nsXPTType& type = param.GetType();
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_ipf64.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_ipf64.cpp
@@ -41,18 +41,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
   paramCount = info->GetParamCount();
 
   // setup variant array pointer
   if(paramCount > PARAM_BUFFER_COUNT)
     dispatchParams = new nsXPTCMiniVariant[paramCount];
   else
     dispatchParams = paramBuffer;
   NS_ASSERTION(dispatchParams,"no place for params");
-  if (! dispatchParams)
-      return NS_ERROR_OUT_OF_MEMORY;
 
   const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
   for(i = 0; i < paramCount; ++i)
   {
     int isfloat = 0;
     const nsXPTParamInfo& param = info->GetParam(i);
     const nsXPTType& type = param.GetType();
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_pa32.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_pa32.cpp
@@ -42,18 +42,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
   paramCount = info->GetParamCount();
 
   // setup variant array pointer
   if(paramCount > PARAM_BUFFER_COUNT)
     dispatchParams = new nsXPTCMiniVariant[paramCount];
   else
     dispatchParams = paramBuffer;
   NS_ASSERTION(dispatchParams,"no place for params");
-  if (!dispatchParams)
-    return NS_ERROR_OUT_OF_MEMORY;
 
   const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
   for(i = 0; i < paramCount; ++i, --args)
   {
     const nsXPTParamInfo& param = info->GetParam(i);
     const nsXPTType& type = param.GetType();
     nsXPTCMiniVariant* dp = &dispatchParams[i];
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc64_linux.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc64_linux.cpp
@@ -55,18 +55,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (! dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint64_t* ap = args;
     uint32_t iCount = 0;
     uint32_t fpCount = 0;
     uint64_t tempu64;
 
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_linux.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_linux.cpp
@@ -54,18 +54,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (! dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint32_t* ap = args;
     uint32_t gpr = 1;    // skip one GPR register
 #ifndef __NO_FPRS__
     uint32_t fpr = 0;
 #endif
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_ppc_openbsd.cpp
@@ -51,18 +51,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint32_t* ap = args;
     uint32_t gpr = 1;    // skip one GPR register
     uint32_t fpr = 0;
     uint32_t tempu32;
     uint64_t tempu64;
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_sparc64_openbsd.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_sparc64_openbsd.cpp
@@ -31,18 +31,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint64_t* ap = args;
     for(i = 0; i < paramCount; i++, ap++)
     {
         const nsXPTParamInfo& param = info->GetParam(i);
         const nsXPTType& type = param.GetType();
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_sparc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_sparc_openbsd.cpp
@@ -40,18 +40,16 @@ PrepareAndDispatch(nsXPTCStubBase* self,
 
     // setup variant array pointer
     if(paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     uint32_t* ap = args;
     for(i = 0; i < paramCount; i++, ap++)
     {
         const nsXPTParamInfo& param = info->GetParam(i);
         const nsXPTType& type = param.GetType();
         nsXPTCMiniVariant* dp = &dispatchParams[i];
 
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_darwin.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_darwin.cpp
@@ -50,18 +50,16 @@ PrepareAndDispatch(nsXPTCStubBase * self
 
     // setup variant array pointer
     if (paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint64_t* ap = args;
     uint32_t nr_gpr = 1;    // skip one GPR register for 'that'
     uint32_t nr_fpr = 0;
     uint64_t value;
 
--- a/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp
+++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp
@@ -50,18 +50,16 @@ PrepareAndDispatch(nsXPTCStubBase * self
 
     // setup variant array pointer
     if (paramCount > PARAM_BUFFER_COUNT)
         dispatchParams = new nsXPTCMiniVariant[paramCount];
     else
         dispatchParams = paramBuffer;
 
     NS_ASSERTION(dispatchParams,"no place for params");
-    if (!dispatchParams)
-        return NS_ERROR_OUT_OF_MEMORY;
 
     const uint8_t indexOfJSContext = info->IndexOfJSContext();
 
     uint64_t* ap = args;
     uint32_t nr_gpr = 1;    // skip one GPR register for 'that'
     uint32_t nr_fpr = 0;
     uint64_t value;
 
--- a/xpcom/tests/gtest/TestPipes.cpp
+++ b/xpcom/tests/gtest/TestPipes.cpp
@@ -92,18 +92,16 @@ class nsReceiver final : public nsIRunna
   nsCOMPtr<nsIInputStream> mIn;
   uint32_t mCount;
 };
 
 NS_IMPL_ISUPPORTS(nsReceiver, nsIRunnable)
 
 static nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsReceiver> receiver = new nsReceiver(in);
-  if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
-
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
 
   uint32_t total = 0;
   PRIntervalTime start = PR_IntervalNow();
@@ -206,18 +204,16 @@ class nsShortReader final : public nsIRu
   uint32_t mReceived;
   ReentrantMonitor* mMon;
 };
 
 NS_IMPL_ISUPPORTS(nsShortReader, nsIRunnable)
 
 static nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsShortReader> receiver = new nsShortReader(in);
-  if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
-
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
 
   uint32_t total = 0;
   for (uint32_t i = 0; i < ITERATIONS; i++) {
--- a/xpcom/tests/windows/TestCOM.cpp
+++ b/xpcom/tests/windows/TestCOM.cpp
@@ -88,20 +88,16 @@ NS_IMPL_ISUPPORTS(nsTestComFactory, nsIF
 nsresult nsTestComFactory::CreateInstance(nsISupports* aOuter,
                                           const nsIID& aIID, void** aResult) {
   if (aOuter != nullptr) {
     return NS_ERROR_NO_AGGREGATION;
   }
 
   nsTestCom* t = new nsTestCom();
 
-  if (t == nullptr) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   NS_ADDREF(t);
   nsresult res = t->QueryInterface(aIID, aResult);
   NS_RELEASE(t);
 
   return res;
 }
 
 TEST(TestCOM, WindowsInterop)