Bug 1525527 - Crash in OOM | large | NS_ABORT_OOM | mozilla::dom::WebSocket::CreateAndDispatchMessageEvent, r=michal
authorMichal Novotny <michal.novotny>
Tue, 19 Feb 2019 08:22:00 +0200
changeset 459897 57c4b2afc95bfb3c444c732802d99c8522414a1b
parent 459896 8c7b302aa952e7a978a10609dc3e3045c0f3d155
child 459898 eccad5d7009c31aa12f7238534bac7d3498af95d
child 459990 b51998b9a11bade0e1f8d6a1646539c37f8f8b46
push id112019
push userdluca@mozilla.com
push dateTue, 19 Feb 2019 18:47:10 +0000
treeherdermozilla-inbound@57c4b2afc95b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1525527
milestone67.0a1
first release with
nightly linux32
57c4b2afc95b / 67.0a1 / 20190219213951 / files
nightly linux64
57c4b2afc95b / 67.0a1 / 20190219213951 / files
nightly mac
57c4b2afc95b / 67.0a1 / 20190219213951 / files
nightly win32
57c4b2afc95b / 67.0a1 / 20190219213951 / files
nightly win64
57c4b2afc95b / 67.0a1 / 20190219213951 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525527 - Crash in OOM | large | NS_ABORT_OOM | mozilla::dom::WebSocket::CreateAndDispatchMessageEvent, r=michal
dom/websocket/WebSocket.cpp
--- a/dom/websocket/WebSocket.cpp
+++ b/dom/websocket/WebSocket.cpp
@@ -1845,17 +1845,20 @@ nsresult WebSocket::CreateAndDispatchMes
       NS_ENSURE_SUCCESS(rv, rv);
       jsData.setObject(*arrayBuf);
     } else {
       MOZ_CRASH("Unknown binary type!");
       return NS_ERROR_UNEXPECTED;
     }
   } else {
     // JS string
-    NS_ConvertUTF8toUTF16 utf16Data(aData);
+    nsAutoString utf16Data;
+    if (!AppendUTF8toUTF16(aData, utf16Data, mozilla::fallible)) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
     JSString* jsString;
     jsString = JS_NewUCStringCopyN(cx, utf16Data.get(), utf16Data.Length());
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
     jsData.setString(jsString);
   }
 
   mImpl->mService->WebSocketMessageAvailable(