8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated
authorccheung
Mon, 09 May 2016 12:20:02 -0700
changeset 38252 f601a770c82f
parent 38249 51b1102fc197
child 38253 dfaea7239a11
8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated Reviewed-by: jiangli, iklam
hotspot/src/share/vm/classfile/classLoader.cpp
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Wed May 04 11:29:05 2016 +0200
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Mon May 09 12:20:02 2016 -0700
@@ -1057,7 +1057,8 @@
     vm_exit_during_initialization(
       "Cannot find ModuleLoaderMap location from modules jimage.", NULL);
   }
-  char* buffer = NEW_RESOURCE_ARRAY(char, size);
+  char* buffer = NEW_RESOURCE_ARRAY(char, size + 1);
+  buffer[size] = '\0';
   jlong read = (*JImageGetResource)(jimage, location, buffer, size);
   if (read != size) {
     vm_exit_during_initialization(