Skip to content

Commit 8de5d20

Browse files
committed
8332865: ubsan: os::attempt_reserve_memory_between reports overflow
Reviewed-by: stuefe, clanger
1 parent f15d423 commit 8de5d20

File tree

1 file changed

+5
-1
lines changed
  • src/hotspot/share/runtime

1 file changed

+5
-1
lines changed

src/hotspot/share/runtime/os.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,11 @@ char* os::attempt_reserve_memory_between(char* min, char* max, size_t bytes, siz
19351935
return nullptr; // overflow
19361936
}
19371937

1938-
char* const hi_att = align_down(MIN2(max, absolute_max) - bytes, alignment_adjusted);
1938+
char* const hi_end = MIN2(max, absolute_max);
1939+
if ((uintptr_t)hi_end < bytes) {
1940+
return nullptr; // no need to go on
1941+
}
1942+
char* const hi_att = align_down(hi_end - bytes, alignment_adjusted);
19391943
if (hi_att > max) {
19401944
return nullptr; // overflow
19411945
}

0 commit comments

Comments
 (0)