Perform a better check of the buffer size in WebSockets.

This commit is contained in:
Pale Moon
2017-08-12 14:05:25 +02:00
committed by Roy Tam
parent 90e4f7f831
commit 392951e9ca
+9 -1
View File
@@ -10,6 +10,7 @@
#include "jsapi.h"
#include "jsfriendapi.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/net/WebSocketChannel.h"
#include "mozilla/dom/File.h"
@@ -2366,7 +2367,14 @@ WebSocket::Send(nsIInputStream* aMsgStream,
}
// Always increment outgoing buffer len, even if closed
mOutgoingBufferedAmount += aMsgLength;
CheckedUint32 size = mOutgoingBufferedAmount;
size += aMsgLength;
if (!size.isValid()) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
mOutgoingBufferedAmount = size.value();
if (readyState == CLOSING ||
readyState == CLOSED) {