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 312896 eb4fb4fef6d483485d520e01d25ad59debfcfb48
parent 312895 3a4835fe862f1651322a0a115907e821b8b4098f
child 312897 57a4d8b83db2fc938aa81fcc139786086a4263b3
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1257389
milestone48.0a1
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)
 {