8315739: Missing null check in os::vm_min_address

Reviewed-by: dholmes, jvernee
This commit is contained in:
Daniel Jeliński 2023-09-21 12:43:53 +00:00
parent 8cbe42b94a
commit 349723cb8d

View File

@ -4254,10 +4254,13 @@ size_t os::vm_min_address() {
static size_t value = 0; static size_t value = 0;
if (value == 0) { if (value == 0) {
assert(is_aligned(_vm_min_address_default, os::vm_allocation_granularity()), "Sanity"); assert(is_aligned(_vm_min_address_default, os::vm_allocation_granularity()), "Sanity");
FILE* f = fopen("/proc/sys/vm/mmap_min_addr", "r"); FILE* f = os::fopen("/proc/sys/vm/mmap_min_addr", "r");
if (f != nullptr) {
if (fscanf(f, "%zu", &value) != 1) { if (fscanf(f, "%zu", &value) != 1) {
value = _vm_min_address_default; value = _vm_min_address_default;
} }
fclose(f);
}
value = MAX2(_vm_min_address_default, value); value = MAX2(_vm_min_address_default, value);
} }
return value; return value;