Bug 1531071 - Add OOM check in TCPSocketParent, r=valentin
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Mar 2019 15:10:03 +0000
changeset 524573 109dd3329637173fca52d796d389e4c4f41f99fe
parent 524572 d9d93f0c41c025c1e9fee4050401f99081ceb3ca
child 524574 0133ea3cd32177ea1da42beff44793eeb2b04010
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1531071
milestone67.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 1531071 - Add OOM check in TCPSocketParent, r=valentin Differential Revision: https://phabricator.services.mozilla.com/D23146
dom/network/TCPSocketParent.cpp
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -223,17 +223,20 @@ mozilla::ipc::IPCResult TCPSocketParent:
   switch (aData.type()) {
     case SendableData::TArrayOfuint8_t: {
       AutoSafeJSContext autoCx;
       JS::Rooted<JS::Value> val(autoCx);
       const nsTArray<uint8_t>& buffer = aData.get_ArrayOfuint8_t();
       bool ok = IPC::DeserializeArrayBuffer(autoCx, buffer, &val);
       NS_ENSURE_TRUE(ok, IPC_OK());
       RootedSpiderMonkeyInterface<ArrayBuffer> data(autoCx);
-      data.Init(&val.toObject());
+      if (!data.Init(&val.toObject())) {
+        TCPSOCKET_LOG(("%s: Failed to allocate memory", __FUNCTION__));
+        return IPC_FAIL_NO_REASON(this);
+      }
       Optional<uint32_t> byteLength(buffer.Length());
       mSocket->SendWithTrackingNumber(autoCx, data, 0, byteLength,
                                       aTrackingNumber, rv);
       break;
     }
 
     case SendableData::TnsCString: {
       const nsCString& strData = aData.get_nsCString();