Bug 1305422 - followup - use correct check for memory allocation failure in nsWindowsRegKey.cpp; r=bustage
authorNathan Froyd <froydnj@mozilla.com>
Fri, 30 Sep 2016 01:56:28 -0400
changeset 315930 3caff20982f80d8649e8c399c3a392a0b623c813
parent 315929 7f7c7197e8ea6311df402e2bf32506f530f59399
child 315931 916c47f534c20427eecbb988453fe2e32004d4c4
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1305422
milestone52.0a1
Bug 1305422 - followup - use correct check for memory allocation failure in nsWindowsRegKey.cpp; r=bustage
xpcom/ds/nsWindowsRegKey.cpp
--- a/xpcom/ds/nsWindowsRegKey.cpp
+++ b/xpcom/ds/nsWindowsRegKey.cpp
@@ -345,17 +345,17 @@ nsWindowsRegKey::ReadStringValue(const n
   // Expand the environment variables if needed
   if (type == REG_EXPAND_SZ) {
     const nsString& flatSource = PromiseFlatString(aResult);
     resultLen = ExpandEnvironmentStringsW(flatSource.get(), nullptr, 0);
     if (resultLen > 1) {
       nsAutoString expandedResult;
       // |resultLen| includes the terminating null character
       --resultLen;
-      if (expandedResult.SetLength(resultLen, mozilla::fallible)) {
+      if (!expandedResult.SetLength(resultLen, mozilla::fallible)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
 
       nsAString::iterator begin;
       expandedResult.BeginWriting(begin);
 
       resultLen = ExpandEnvironmentStringsW(flatSource.get(),
                                             wwc(begin.get()),
@@ -417,17 +417,17 @@ nsWindowsRegKey::ReadBinaryValue(const n
     return NS_ERROR_FAILURE;
   }
 
   if (!size) {
     aResult.Truncate();
     return NS_OK;
   }
 
-  if (aResult.SetLength(size, mozilla::fallible)) {
+  if (!aResult.SetLength(size, mozilla::fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsACString::iterator begin;
   aResult.BeginWriting(begin);
 
   rv = RegQueryValueExW(mKey, PromiseFlatString(aName).get(), 0, nullptr,
                         (LPBYTE)begin.get(), &size);