Bug 820373 - Add a null check to TextEncoder.encode(). r=bz, a=akeybl
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 16 Dec 2012 19:51:11 -0500
changeset 117596 b02a32dfc7a798988e225efd9255d385687516aa
parent 117595 8fc480e6cfdc4f5ace15e21336d5b304f0636d78
child 117597 ed2b1f04fed03fcccf1af932b9bb0a55cfb5705c
child 117599 44d7fada9eede3501c247ab88debcf6846f1b9fd
child 117602 4af665f1dff4b13dccb9c3fada7c3d4f997b3960
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersbz, akeybl
bugs820373
milestone18.0
Bug 820373 - Add a null check to TextEncoder.encode(). r=bz, a=akeybl
dom/encoding/TextEncoder.cpp
--- a/dom/encoding/TextEncoder.cpp
+++ b/dom/encoding/TextEncoder.cpp
@@ -95,16 +95,20 @@ TextEncoder::Encode(JSContext* aCx,
     }
   }
 
   JSObject* outView = nullptr;
   if (NS_SUCCEEDED(rv)) {
     buf[dstLen] = '\0';
     outView = Uint8Array::Create(aCx, this, dstLen,
                                  reinterpret_cast<uint8_t*>(buf.get()));
+    if (!outView) {
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+      return nullptr;
+    }
   }
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
   return outView;
 }