Bug 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz a=sylvestre
authorKyle Huey <khuey@kylehuey.com>
Wed, 16 Mar 2016 20:04:10 -0700
changeset 323578 f8845ecc6bee077a8ce5fc4f8128b4b935313431
parent 323577 559e13fd5a47aab3210e763c8f8ff9bcaa930b0d
child 323579 f9afa1afdde0261a2eaa5c9d40ab7fbc0ae4788d
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1257389
milestone47.0a2
Bug 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz a=sylvestre MozReview-Commit-ID: LazPp0invce
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2436,17 +2436,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)
 {