Bug 820373 - Add a null check to TextEncoder.encode(). r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 16 Dec 2012 19:51:11 -0500
changeset 125332 22f0a7ee5348e6b71faf49a796564b40374bf80d
parent 125331 9637f34d0df031ef90eff67f01658b7f50d77b7f
child 125333 11bf35befda610a420c7b191319b4b2581ade56e
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs820373
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 820373 - Add a null check to TextEncoder.encode(). r=bz
dom/encoding/TextEncoder.cpp
--- a/dom/encoding/TextEncoder.cpp
+++ b/dom/encoding/TextEncoder.cpp
@@ -85,16 +85,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;
 }