From f00a582ac40aba85d14c5f91c1d3b2f96ec264b5 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 16 Mar 2016 20:04:10 -0700 Subject: [PATCH] Bug 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz --HG-- extra : rebase_source : 904526e9c7ef9a90ac0bb73984af5d95dd8e60fc --- dom/bindings/BindingUtils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 93b6cd4bd14c..84272a395396 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -2452,7 +2452,10 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle v, 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;