mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Check if the size exceeds the maximum allowed size for TypedArray construction
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
78576a5af9
commit
685a71c3d1
1 changed files with 6 additions and 0 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include "runtime/AsyncFromSyncIteratorObject.h"
|
||||
#include "runtime/ScriptAsyncFunctionObject.h"
|
||||
#include "runtime/StringObject.h"
|
||||
#include "runtime/ArrayBuffer.h"
|
||||
|
||||
namespace Escargot {
|
||||
|
||||
|
|
@ -227,6 +228,11 @@ ValueVectorWithInlineStorage IteratorObject::iterableToList(ExecutionState& stat
|
|||
if (next.hasValue()) {
|
||||
Value nextValue = IteratorObject::iteratorValue(state, next.value());
|
||||
values.pushBack(nextValue);
|
||||
// Check if the size exceeds the maximum allowed size for TypedArray construction
|
||||
// This prevents memory exhaustion when iterating over very large sparse arrays
|
||||
if (values.size() >= ArrayBuffer::maxArrayBufferSize) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue