8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated

Reviewed-by: jiangli, iklam
This commit is contained in:
Calvin Cheung 2016-05-09 12:20:02 -07:00
parent fdc03a7cd8
commit fef5de6f41

View File

@ -1057,7 +1057,8 @@ void ClassLoader::initialize_module_loader_map(JImageFile* jimage) {
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(