Bug 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz
authorKyle Huey <khuey@kylehuey.com>
Wed, 16 Mar 2016 20:04:10 -0700
changeset 289122 eb4fb4fef6d483485d520e01d25ad59debfcfb48
parent 289121 3a4835fe862f1651322a0a115907e821b8b4098f
child 289123 57a4d8b83db2fc938aa81fcc139786086a4263b3
push id30096
push usercbook@mozilla.com
push dateThu, 17 Mar 2016 10:00:34 +0000
treeherdermozilla-central@fefe2bc3e54f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1257389
milestone48.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 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2447,17 +2447,20 @@ ConvertJSValueToByteString(JSContext* cx
     }
   } else {
     length = js::GetStringLength(s);
   }
 
   static_assert(js::MaxStringLength < UINT32_MAX,
                 "length+1 shouldn't overflow");
 
-  result.SetLength(length);
+  if (!result.SetLength(length, fallible)) {
+    return false;
+  }
+
   JS_EncodeStringToBuffer(cx, s, result.BeginWriting(), length);
 
   return true;
 }
 
 bool
 IsInPrivilegedApp(JSContext* aCx, JSObject* aObj)
 {