Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: src/elements.cc

Issue 2219803002: [keys] Throw a range error if the number of keys overflow FixedArray::kMaxLength (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/elements.h ('k') | src/keys.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index b10e1f7f1b8309213ead099b5c856afcb39d1e5f..29fa4fb08c8bdaef6bda5d26794b4deab44a962c 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1030,16 +1030,15 @@ class ElementsAccessorBase : public ElementsAccessor {
return list;
}
- Handle<FixedArray> PrependElementIndices(Handle<JSObject> object,
- Handle<FixedArrayBase> backing_store,
- Handle<FixedArray> keys,
- GetKeysConversion convert,
- PropertyFilter filter) final {
+ MaybeHandle<FixedArray> PrependElementIndices(
+ Handle<JSObject> object, Handle<FixedArrayBase> backing_store,
+ Handle<FixedArray> keys, GetKeysConversion convert,
+ PropertyFilter filter) final {
return Subclass::PrependElementIndicesImpl(object, backing_store, keys,
convert, filter);
}
- static Handle<FixedArray> PrependElementIndicesImpl(
+ static MaybeHandle<FixedArray> PrependElementIndicesImpl(
Handle<JSObject> object, Handle<FixedArrayBase> backing_store,
Handle<FixedArray> keys, GetKeysConversion convert,
PropertyFilter filter) {
@@ -1048,6 +1047,11 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t initial_list_length =
Subclass::GetMaxNumberOfEntries(*object, *backing_store);
initial_list_length += nof_property_keys;
+ if (initial_list_length > FixedArray::kMaxLength ||
+ initial_list_length < nof_property_keys) {
+ return isolate->Throw<FixedArray>(isolate->factory()->NewRangeError(
+ MessageTemplate::kInvalidArrayLength));
+ }
bool needs_sorting =
IsDictionaryElementsKind(kind()) || IsSloppyArgumentsElements(kind());
« no previous file with comments | « src/elements.h ('k') | src/keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698