8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated
Reviewed-by: jiangli, iklam
--- 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(