8327986: ASAN reports use-after-free in DirectivesParserTest.empty_object_vm

Reviewed-by: kvn, djelinski
This commit is contained in:
Thomas Stuefe 2024-03-28 07:09:43 +00:00
parent d580bcf956
commit 47f33a59ea

View File

@ -31,15 +31,16 @@
class DirectivesParserTest : public ::testing::Test{ class DirectivesParserTest : public ::testing::Test{
protected: protected:
const char* const _locale; char* const _locale;
ResourceMark rm; ResourceMark rm;
stringStream stream; stringStream stream;
// These tests require the "C" locale to correctly parse decimal values // 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"); setlocale(LC_NUMERIC, "C");
} }
~DirectivesParserTest() { ~DirectivesParserTest() {
setlocale(LC_NUMERIC, _locale); setlocale(LC_NUMERIC, _locale);
os::free(_locale);
} }
void test_negative(const char* text) { void test_negative(const char* text) {