From 40c5edfcc4ad98af435d2edf3dd40f20f24fca46 Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 3 Mar 2023 18:07:40 +0000 Subject: [PATCH] 8303181: Memory leak in ClassLoaderExt::setup_app_search_path Reviewed-by: ccheung, dholmes --- src/hotspot/share/classfile/classLoaderExt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 23c017b7d01..1a1cc591d94 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -67,7 +67,7 @@ void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) { void ClassLoaderExt::setup_app_search_path(JavaThread* current) { Arguments::assert_is_dumping_archive(); _app_class_paths_start_index = ClassLoader::num_boot_classpath_entries(); - char* app_class_path = os::strdup(Arguments::get_appclasspath()); + char* app_class_path = os::strdup_check_oom(Arguments::get_appclasspath(), mtClass); if (strcmp(app_class_path, ".") == 0) { // This doesn't make any sense, even for AppCDS, so let's skip it. We @@ -78,6 +78,8 @@ void ClassLoaderExt::setup_app_search_path(JavaThread* current) { trace_class_path("app loader class path=", app_class_path); ClassLoader::setup_app_search_path(current, app_class_path); } + + os::free(app_class_path); } void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable* met) {