Bug 1298804 - Missing OOM check in getCloneBuffer, r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 08 Sep 2016 16:23:47 -0700
changeset 357615 2e5657392d4756c6c72bd7b29eb28756dcf1cd9d
parent 357614 b1df9ae6cce2e3766c7d9c7521a32b5e6bfb7161
child 357616 2eaed28b43939187dc169a9ce0951eda5957673a
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1298804
milestone51.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 1298804 - Missing OOM check in getCloneBuffer, r=jonco
js/src/builtin/TestingFunctions.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2139,16 +2139,20 @@ class CloneBufferObject : public NativeO
 
         if (hasTransferable) {
             JS_ReportError(cx, "cannot retrieve structured clone buffer with transferables");
             return false;
         }
 
         size_t size = obj->data()->Size();
         UniqueChars buffer(static_cast<char*>(js_malloc(size)));
+        if (!buffer) {
+            ReportOutOfMemory(cx);
+            return false;
+        }
         auto iter = obj->data()->Iter();
         obj->data()->ReadBytes(iter, buffer.get(), size);
         JSString* str = JS_NewStringCopyN(cx, buffer.get(), size);
         if (!str)
             return false;
         args.rval().setString(str);
         return true;
     }