From 349723cb8dd7a5e496f348dc8689431480ef1083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Jeli=C5=84ski?= Date: Thu, 21 Sep 2023 12:43:53 +0000 Subject: [PATCH] 8315739: Missing null check in os::vm_min_address Reviewed-by: dholmes, jvernee --- src/hotspot/os/linux/os_linux.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 019046c4f9b..594898cd805 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -4254,9 +4254,12 @@ size_t os::vm_min_address() { static size_t value = 0; if (value == 0) { assert(is_aligned(_vm_min_address_default, os::vm_allocation_granularity()), "Sanity"); - FILE* f = fopen("/proc/sys/vm/mmap_min_addr", "r"); - if (fscanf(f, "%zu", &value) != 1) { - value = _vm_min_address_default; + FILE* f = os::fopen("/proc/sys/vm/mmap_min_addr", "r"); + if (f != nullptr) { + if (fscanf(f, "%zu", &value) != 1) { + value = _vm_min_address_default; + } + fclose(f); } value = MAX2(_vm_min_address_default, value); }