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 358773 3caff20982f80d8649e8c399c3a392a0b623c813
parent 358772 7f7c7197e8ea6311df402e2bf32506f530f59399
child 358774 916c47f534c20427eecbb988453fe2e32004d4c4
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1305422
milestone52.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 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);