summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorOlli Pettay <Olli.Pettay@helsinki.fi>2021-12-08 17:10:16 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-07 23:49:05 +0200
commitc265d1cb7ca98616426ee7c0a3d7cc0dd1a4cc50 (patch)
tree78c71b13e9cd98a9d3edde199fbca4933bfafdbc /dom
parentd61076d50e400e98d60a4168279ef05b6e479422 (diff)
downloaduxp-c265d1cb7ca98616426ee7c0a3d7cc0dd1a4cc50.tar.gz
[DOM] Don't try to create too large string buffers
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsStructuredCloneContainer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/dom/base/nsStructuredCloneContainer.cpp b/dom/base/nsStructuredCloneContainer.cpp
index 6e3a692568..fb9f0286d5 100644
--- a/dom/base/nsStructuredCloneContainer.cpp
+++ b/dom/base/nsStructuredCloneContainer.cpp
@@ -15,6 +15,7 @@
#include "xpcpublic.h"
#include "mozilla/Base64.h"
+#include "mozilla/CheckedInt.h"
#include "mozilla/dom/ScriptSettings.h"
using namespace mozilla;
@@ -138,6 +139,11 @@ nsStructuredCloneContainer::GetDataAsBase64(nsAString &aOut)
auto iter = Data().Start();
size_t size = Data().Size();
+ CheckedInt<nsAutoCString::size_type> sizeCheck(size);
+ if (!sizeCheck.isValid()) {
+ return NS_ERROR_FAILURE;
+ }
+
nsAutoCString binaryData;
binaryData.SetLength(size);
Data().ReadBytes(iter, binaryData.BeginWriting(), size);