Bug 1455693: Check for memory allocation failures in FormatWasmFrame; r=yury
authorBenjamin Bouvier <benj@benj.me>
Mon, 23 Apr 2018 16:21:39 +0200
changeset 415311 8076e3b5771825ae8d3437a7665e8c8102657d0a
parent 415310 16a7ab26c645d8201aba76ddeee9322514e69bef
child 415312 d0fe2832896c1449e90294bbc2920df053a8fda5
push id33894
push usercbrindusan@mozilla.com
push dateTue, 24 Apr 2018 21:51:36 +0000
treeherdermozilla-central@6eeb97ca94f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyury
bugs1455693
milestone61.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 1455693: Check for memory allocation failures in FormatWasmFrame; r=yury
js/src/jsfriendapi.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1046,31 +1046,36 @@ FormatFrame(JSContext* cx, const FrameIt
 
     MOZ_ASSERT(!cx->isExceptionPending());
     return buf;
 }
 
 static JS::UniqueChars
 FormatWasmFrame(JSContext* cx, const FrameIter& iter, JS::UniqueChars&& inBuf, int num)
 {
-    JSAtom* functionDisplayAtom = iter.functionDisplayAtom();
     UniqueChars nameStr;
-    if (functionDisplayAtom)
+    if (JSAtom* functionDisplayAtom = iter.functionDisplayAtom()) {
         nameStr = StringToNewUTF8CharsZ(cx, *functionDisplayAtom);
+        if (!nameStr)
+            return nullptr;
+    }
 
     JS::UniqueChars buf = sprintf_append(cx, Move(inBuf), "%d %s()",
                                          num,
                                          nameStr ? nameStr.get() : "<wasm-function>");
     if (!buf)
         return nullptr;
+
     const char* filename = iter.filename();
     uint32_t lineno = iter.computeLine();
     buf = sprintf_append(cx, Move(buf), " [\"%s\":%d]\n",
                          filename ? filename : "<unknown>",
                          lineno);
+    if (!buf)
+        return nullptr;
 
     MOZ_ASSERT(!cx->isExceptionPending());
     return buf;
 }
 
 JS_FRIEND_API(JS::UniqueChars)
 JS::FormatStackDump(JSContext* cx, JS::UniqueChars&& inBuf, bool showArgs, bool showLocals,
                     bool showThisProps)