Bug 1167423 - patch 2 - Handle return values of FallibleTArray functions in WebSocket, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 25 May 2015 12:50:15 +0100
changeset 245463 84ea22e04a6272a6291797e8638c258ee18a69dd
parent 245462 fc7b8402d18bf9b6d12419cfbc3d9a7246fda85c
child 245464 c85d3209f1578e50c9857018161a99e47fe31e58
push id28806
push userphilringnalda@gmail.com
push dateTue, 26 May 2015 02:10:16 +0000
treeherdermozilla-central@4362d9251296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1167423
milestone41.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 1167423 - patch 2 - Handle return values of FallibleTArray functions in WebSocket, r=smaug
dom/base/WebSocket.cpp
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -955,17 +955,21 @@ WebSocket::Constructor(const GlobalObjec
 
 already_AddRefed<WebSocket>
 WebSocket::Constructor(const GlobalObject& aGlobal,
                        const nsAString& aUrl,
                        const nsAString& aProtocol,
                        ErrorResult& aRv)
 {
   Sequence<nsString> protocols;
-  protocols.AppendElement(aProtocol);
+  if (!protocols.AppendElement(aProtocol)) {
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+    return nullptr;
+  }
+
   return WebSocket::Constructor(aGlobal, aUrl, protocols, aRv);
 }
 
 namespace {
 
 // This class is used to clear any exception.
 class MOZ_STACK_CLASS ClearException
 {