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

Unified Diff: src/elements.cc

Issue 1863553003: [elements] Fix length bounds precheck for Array.prototype.concat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: compare properly Created 4 years, 8 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/builtins.cc ('k') | test/mjsunit/regress/regress-599414-array-concat-fast-path.js » ('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 3d176aef8033433615fa428fd6298533ac8bf34b..288c60e30515a5874042824c406406d9ba598ffc 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -2978,6 +2978,9 @@ void ElementsAccessor::TearDown() {
Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
uint32_t concat_size) {
+ const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
+ STATIC_ASSERT(FixedDoubleArray::kMaxLength < kHalfOfMaxInt);
+ USE(kHalfOfMaxInt);
uint32_t result_len = 0;
bool has_raw_doubles = false;
ElementsKind result_elements_kind = GetInitialFastElementsKind();
@@ -2992,9 +2995,6 @@ Handle<JSArray> ElementsAccessor::Concat(Isolate* isolate, Arguments* args,
array->length()->ToArrayLength(&len);
// We shouldn't overflow when adding another len.
- const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
- STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt);
- USE(kHalfOfMaxInt);
result_len += len;
DCHECK(0 <= result_len);
DCHECK(result_len <= FixedDoubleArray::kMaxLength);
« no previous file with comments | « src/builtins.cc ('k') | test/mjsunit/regress/regress-599414-array-concat-fast-path.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698