Bug 969133 - OdinMonkey: fix leak in validation error message (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Fri, 07 Feb 2014 10:25:16 -0600
changeset 167558 be7fa3989aed89ab758fcc5c8b7ef6e9bd1d67d4
parent 167556 dad17d2dcf2828cfaf33dbfffef37899aee51885
child 167559 c8a74e6f8159673cc2c4d6e1486c16d8f186dc42
push id26174
push userkwierso@gmail.com
push dateSat, 08 Feb 2014 00:55:48 +0000
treeherdermozilla-central@2c873eff7dc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs969133
milestone30.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 969133 - OdinMonkey: fix leak in validation error message (r=bbouvier)
js/src/jit/AsmJSLink.cpp
--- a/js/src/jit/AsmJSLink.cpp
+++ b/js/src/jit/AsmJSLink.cpp
@@ -231,27 +231,35 @@ DynamicallyLinkModule(JSContext *cx, Cal
     Rooted<ArrayBufferObject*> heap(cx);
     if (module.hasArrayView()) {
         if (!IsTypedArrayBuffer(bufferVal))
             return LinkFail(cx, "bad ArrayBuffer argument");
 
         heap = &bufferVal.toObject().as<ArrayBufferObject>();
 
         if (!IsValidAsmJSHeapLength(heap->byteLength())) {
-            return LinkFail(cx, JS_smprintf("ArrayBuffer byteLength 0x%x is not a valid heap length. The next valid length is 0x%x",
-                                            heap->byteLength(),
-                                            RoundUpToNextValidAsmJSHeapLength(heap->byteLength())));
+            ScopedJSFreePtr<char> msg(
+                JS_smprintf("ArrayBuffer byteLength 0x%x is not a valid heap length. The next "
+                            "valid length is 0x%x",
+                            heap->byteLength(),
+                            RoundUpToNextValidAsmJSHeapLength(heap->byteLength())));
+            return LinkFail(cx, msg.get());
         }
 
         // This check is sufficient without considering the size of the loaded datum because heap
         // loads and stores start on an aligned boundary and the heap byteLength has larger alignment.
         JS_ASSERT((module.minHeapLength() - 1) <= INT32_MAX);
         if (heap->byteLength() < module.minHeapLength()) {
-            return LinkFail(cx, JS_smprintf("ArrayBuffer byteLength of 0x%x is less than 0x%x (which is the largest constant heap access offset rounded up to the next valid heap size).",
-                                            heap->byteLength(), module.minHeapLength()));
+            ScopedJSFreePtr<char> msg(
+                JS_smprintf("ArrayBuffer byteLength of 0x%x is less than 0x%x (which is the"
+                            "largest constant heap access offset rounded up to the next valid "
+                            "heap size).",
+                            heap->byteLength(),
+                            module.minHeapLength()));
+            return LinkFail(cx, msg.get());
         }
 
         if (!ArrayBufferObject::prepareForAsmJS(cx, heap))
             return LinkFail(cx, "Unable to prepare ArrayBuffer for asm.js use");
 
         module.initHeap(heap, cx);
     }