From 47f33a59eaaffc74881fcc9e29d13ff9b2538c2a Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 28 Mar 2024 07:09:43 +0000 Subject: [PATCH] 8327986: ASAN reports use-after-free in DirectivesParserTest.empty_object_vm Reviewed-by: kvn, djelinski --- test/hotspot/gtest/compiler/test_directivesParser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/hotspot/gtest/compiler/test_directivesParser.cpp b/test/hotspot/gtest/compiler/test_directivesParser.cpp index 2e36e09ccc1..7b78186316e 100644 --- a/test/hotspot/gtest/compiler/test_directivesParser.cpp +++ b/test/hotspot/gtest/compiler/test_directivesParser.cpp @@ -31,15 +31,16 @@ class DirectivesParserTest : public ::testing::Test{ protected: - const char* const _locale; + char* const _locale; ResourceMark rm; stringStream stream; // These tests require the "C" locale to correctly parse decimal values - DirectivesParserTest() : _locale(setlocale(LC_NUMERIC, nullptr)) { + DirectivesParserTest() : _locale(os::strdup(setlocale(LC_NUMERIC, nullptr), mtTest)) { setlocale(LC_NUMERIC, "C"); } ~DirectivesParserTest() { setlocale(LC_NUMERIC, _locale); + os::free(_locale); } void test_negative(const char* text) {