mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 14:54:25 +00:00
Bug 1738237, don't try to create too large string buffers, r=mccr8, a=RyanVM
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user