Bug 729910 - Fix OOM in gc() shell function (r=luke)
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 23 Feb 2012 14:34:18 -0800
changeset 87585 f00bab9999f9640ffc82221d901d1b23d8991982
parent 87584 24dd2472229fb4abbb516b3887de55ca58913b03
child 87586 c2c2a5b0c313ccd75760ebd5437421b49d69ed71
push id22133
push usermak77@bonardo.net
push dateFri, 24 Feb 2012 10:23:30 +0000
treeherdermozilla-central@fbcdc2c87df8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs729910
milestone13.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 729910 - Fix OOM in gc() shell function (r=luke)
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1269,17 +1269,20 @@ GC(JSContext *cx, uintN argc, jsval *vp)
                 (unsigned long)preBytes, (unsigned long)cx->runtime->gcBytes,
 #ifdef HAVE_SBRK
                 (unsigned long)sbrk(0)
 #else
                 0
 #endif
                 );
 #endif
-    *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
+    JSString *str = JS_NewStringCopyZ(cx, buf);
+    if (!str)
+        return false;
+    *vp = STRING_TO_JSVAL(str);
     return true;
 }
 
 static const struct ParamPair {
     const char      *name;
     JSGCParamKey    param;
 } paramMap[] = {
     {"maxBytes",            JSGC_MAX_BYTES },