Skip to content

Commit 22793da

Browse files
committed
v8: fix --max_old_space_size=4096 integer overflow
See https://code.google.com/p/v8/issues/detail?id=3857 for the bug report and https://codereview.chromium.org/897543002 for the CL. PR-URL: #1166 Reviewed-By: Fedor Indutny <[email protected]>
1 parent b2e00e3 commit 22793da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

deps/v8/src/heap/heap.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -5082,21 +5082,22 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
50825082
max_semi_space_size_ = max_semi_space_size * MB;
50835083
}
50845084
if (max_old_space_size > 0) {
5085-
max_old_generation_size_ = max_old_space_size * MB;
5085+
max_old_generation_size_ = static_cast<intptr_t>(max_old_space_size) * MB;
50865086
}
50875087
if (max_executable_size > 0) {
5088-
max_executable_size_ = max_executable_size * MB;
5088+
max_executable_size_ = static_cast<intptr_t>(max_executable_size) * MB;
50895089
}
50905090

50915091
// If max space size flags are specified overwrite the configuration.
50925092
if (FLAG_max_semi_space_size > 0) {
50935093
max_semi_space_size_ = FLAG_max_semi_space_size * MB;
50945094
}
50955095
if (FLAG_max_old_space_size > 0) {
5096-
max_old_generation_size_ = FLAG_max_old_space_size * MB;
5096+
max_old_generation_size_ =
5097+
static_cast<intptr_t>(FLAG_max_old_space_size) * MB;
50975098
}
50985099
if (FLAG_max_executable_size > 0) {
5099-
max_executable_size_ = FLAG_max_executable_size * MB;
5100+
max_executable_size_ = static_cast<intptr_t>(FLAG_max_executable_size) * MB;
51005101
}
51015102

51025103
if (FLAG_stress_compaction) {

0 commit comments

Comments
 (0)