Bug 1531071 - Add OOM check in TCPSocketParent, r=valentin
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Mar 2019 15:10:03 +0000
changeset 521575 109dd3329637
parent 521574 d9d93f0c41c0
child 521576 0133ea3cd321
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [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();