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 119101 28932b5006920b37c01ac00f97a251b57460147e
parent 119100 c02926efc5faa6fc42bf18933ff34f9d32585f67
child 119102 86d252d055a28ef38608d2964a55fbee1d95a97c
push id3055
push userVYV03354@nifty.ne.jp
push dateWed, 26 Dec 2012 10:30:21 +0000
treeherdermozilla-aurora@28932b500692 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, akeybl
bugs820373
milestone19.0a2
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
@@ -89,16 +89,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;
 }