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 517779 57c4b2afc95b
parent 517778 8c7b302aa952
child 517830 b51998b9a11b
child 517855 eccad5d7009c
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [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(