Bug 1231309 - guard sz with assert. r=bobbyholley
authorBogdan Postelnicu <bogdan.postelnicu>
Thu, 10 Dec 2015 08:10:00 +0100
changeset 310337 8dfb9aeac3af19e6d0b816b45cca5c5950d35b49
parent 310336 f323171fbb4982fb78c3c092299b49ce48aaeba7
child 310338 e8b02a6a50d2a5c864d636931296d51e4fd89c4c
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobbyholley
bugs1231309
milestone45.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 1231309 - guard sz with assert. r=bobbyholley
js/xpconnect/src/XPCThrower.cpp
--- a/js/xpconnect/src/XPCThrower.cpp
+++ b/js/xpconnect/src/XPCThrower.cpp
@@ -73,16 +73,17 @@ XPCThrower::Throw(nsresult rv, XPCCallCo
 
     if (CheckForPendingException(rv, ccx))
         return;
 
     if (!nsXPCException::NameAndFormatForNSResult(rv, nullptr, &format))
         format = "";
 
     sz = (char*) format;
+    NS_ENSURE_TRUE_VOID(sz);
 
     if (sz && sVerbose)
         Verbosify(ccx, &sz, false);
 
     dom::Throw(ccx, rv, nsDependentCString(sz));
 
     if (sz && sz != format)
         JS_smprintf_free(sz);
@@ -114,16 +115,17 @@ XPCThrower::ThrowBadResult(nsresult rv, 
 
     if (!nsXPCException::NameAndFormatForNSResult(rv, nullptr, &format) || !format)
         format = "";
 
     if (nsXPCException::NameAndFormatForNSResult(result, &name, nullptr) && name)
         sz = JS_smprintf("%s 0x%x (%s)", format, result, name);
     else
         sz = JS_smprintf("%s 0x%x", format, result);
+    NS_ENSURE_TRUE_VOID(sz);
 
     if (sz && sVerbose)
         Verbosify(ccx, &sz, true);
 
     dom::Throw(ccx, result, nsDependentCString(sz));
 
     if (sz)
         JS_smprintf_free(sz);
@@ -135,16 +137,17 @@ XPCThrower::ThrowBadParam(nsresult rv, u
 {
     char* sz;
     const char* format;
 
     if (!nsXPCException::NameAndFormatForNSResult(rv, nullptr, &format))
         format = "";
 
     sz = JS_smprintf("%s arg %d", format, paramNum);
+    NS_ENSURE_TRUE_VOID(sz);
 
     if (sz && sVerbose)
         Verbosify(ccx, &sz, true);
 
     dom::Throw(ccx, rv, nsDependentCString(sz));
 
     if (sz)
         JS_smprintf_free(sz);