Bug 1161628 - Fix leak in ErrorWrongTypeArg. r=bbouvier
authorTooru Fujisawa <arai_a@mac.com>
Wed, 06 May 2015 15:44:31 +0900
changeset 273945 5b06411e7a5b8ec426dde3ced579ff55232c8a5a
parent 273885 bbe25ecbebdaa2a5e955f0b6789a9fcc43faddd5
child 273946 a02ea85607a2c0989f057053858125fa5046763b
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1161628
milestone40.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 1161628 - Fix leak in ErrorWrongTypeArg. r=bbouvier
js/src/builtin/SIMD.cpp
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -73,18 +73,23 @@ ErrorBadArgs(JSContext* cx)
 static inline bool
 ErrorWrongTypeArg(JSContext* cx, size_t argIndex, Handle<TypeDescr*> typeDescr)
 {
     MOZ_ASSERT(argIndex < 10);
     char charArgIndex[2];
     JS_snprintf(charArgIndex, sizeof charArgIndex, "%d", argIndex);
 
     HeapSlot& typeNameSlot = typeDescr->getReservedSlotRef(JS_DESCR_SLOT_STRING_REPR);
+    char* typeNameStr = JS_EncodeString(cx, typeNameSlot.toString());
+    if (!typeNameStr)
+        return false;
+
     JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SIMD_NOT_A_VECTOR,
-                         JS_EncodeString(cx, typeNameSlot.toString()), charArgIndex);
+                         typeNameStr, charArgIndex);
+    JS_free(cx, typeNameStr);
     return false;
 }
 
 template<typename V>
 bool
 js::ToSimdConstant(JSContext* cx, HandleValue v, jit::SimdConstant* out)
 {
     typedef typename V::Elem Elem;