Bug 945568 - Properly handle OOM in ReadFile. r=terrence
authorChristian Holler <choller@mozilla.com>
Tue, 03 Dec 2013 03:33:55 +0100
changeset 174199 bb06cc9a70886e3725f6e960ef0ba6d709056325
parent 174198 3ac6ea6491a85377e2c044d28a01f85d12a55076
child 174200 185f4a23a4cde299940096ea16b3212ebd598fcd
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs945568
milestone28.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 945568 - Properly handle OOM in ReadFile. r=terrence
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3385,16 +3385,19 @@ ReadFile(JSContext *cx, unsigned argc, j
 
     if (!args[0].isString() || (args.length() == 2 && !args[1].isString())) {
         JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "snarf");
         return false;
     }
 
     RootedString givenPath(cx, args[0].toString());
     RootedString str(cx, ResolvePath(cx, givenPath, scriptRelative));
+    if (!str)
+        return false;
+
     JSAutoByteString filename(cx, str);
     if (!filename)
         return false;
 
     if (args.length() > 1) {
         JSString *opt = JS::ToString(cx, args[1]);
         if (!opt)
             return false;