changeset 11197:f86a34e67a05

8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated Reviewed-by: jiangli, iklam
author ccheung
date Mon, 09 May 2016 12:20:02 -0700
parents 8e0fe2ce0d9b
children 8bfef5982e56
files src/share/vm/classfile/classLoader.cpp
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/classLoader.cpp	Wed May 04 11:29:05 2016 +0200
+++ b/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(