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 317580 391e44f7849fd2d13c22f33f29cb1ff81d74439f
parent 317579 963854e6252db7dbc0f71a8317fe0e48ae53ef15
child 317581 243d8088e03b94a25a47e8edbcf6af694812b309
push id5799
push userkwierso@gmail.com
push dateWed, 23 Mar 2016 23:48:12 +0000
treeherdermozilla-beta@ccb10eb47738 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1257389
milestone46.0
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
@@ -2419,17 +2419,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)
 {