# HG changeset patch # User mikael # Date 1549506852 28800 # Node ID 2f4c2bc90b22c1605d6dced22b045cf037a4a361 # Parent 7870ecf291ccbb1ac82e802832c422fb2d774ac3 8218581: Incorrect exception message generation Reviewed-by: hseigel diff -r 7870ecf291cc -r 2f4c2bc90b22 src/hotspot/share/classfile/modules.cpp --- a/src/hotspot/share/classfile/modules.cpp Thu Feb 07 02:48:11 2019 +0100 +++ b/src/hotspot/share/classfile/modules.cpp Wed Feb 06 18:34:12 2019 -0800 @@ -334,8 +334,8 @@ (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) { const char* class_loader_name = loader_data->loader_name_and_id(); size_t pkg_len = strlen(package_name); - char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len); - strncpy(pkg_name, package_name, pkg_len); + char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len + 1); + strncpy(pkg_name, package_name, pkg_len + 1); StringUtils::replace_no_expand(pkg_name, "/", "."); const char* msg_text1 = "Class loader (instance of): "; const char* msg_text2 = " tried to define prohibited package name: ";