8132892: Memory must be freed after calling Arguments::set_sysclasspath function
authorddmitriev
Sun, 09 Aug 2015 13:38:24 +0300
changeset 32198 be9ac7dad761
parent 32197 ced75b2e81d4
child 32199 85ad3259f1c6
child 32200 994e76a280d4
8132892: Memory must be freed after calling Arguments::set_sysclasspath function Summary: Free memory after calling set_sysclasspath Reviewed-by: dholmes, dcubed
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/os.cpp
--- 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;
 }