changeset 32198:be9ac7dad761

8132892: Memory must be freed after calling Arguments::set_sysclasspath function Summary: Free memory after calling set_sysclasspath Reviewed-by: dholmes, dcubed
author ddmitriev
date Sun, 09 Aug 2015 13:38:24 +0300
parents ced75b2e81d4
children 85ad3259f1c6 994e76a280d4
files hotspot/src/share/vm/runtime/arguments.cpp hotspot/src/share/vm/runtime/os.cpp
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Fri Aug 07 17:14:26 2015 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Sun Aug 09 13:38:24 2015 +0300
@@ -3305,7 +3305,9 @@
 
   if (scp_assembly_required) {
     // Assemble the bootclasspath elements into the final path.
-    Arguments::set_sysclasspath(scp_p->combined_path());
+    char *combined_path = scp_p->combined_path();
+    Arguments::set_sysclasspath(combined_path);
+    FREE_C_HEAP_ARRAY(char, combined_path);
   }
 
   // This must be done after all arguments have been processed.
--- a/hotspot/src/share/vm/runtime/os.cpp	Fri Aug 07 17:14:26 2015 -0700
+++ b/hotspot/src/share/vm/runtime/os.cpp	Sun Aug 09 13:38:24 2015 +0300
@@ -1271,6 +1271,7 @@
   bool has_jimage = (os::stat(jimage, &st) == 0);
   if (has_jimage) {
     Arguments::set_sysclasspath(jimage);
+    FREE_C_HEAP_ARRAY(char, jimage);
     return true;
   }
   FREE_C_HEAP_ARRAY(char, jimage);
@@ -1282,6 +1283,7 @@
       sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
     }
   }
+  FREE_C_HEAP_ARRAY(char, modules_dir);
 
   // fallback to classes
   if (sysclasspath == NULL)
@@ -1289,6 +1291,7 @@
 
   if (sysclasspath == NULL) return false;
   Arguments::set_sysclasspath(sysclasspath);
+  FREE_C_HEAP_ARRAY(char, sysclasspath);
 
   return true;
 }