8218581: Incorrect exception message generation
authormikael
Wed, 06 Feb 2019 18:34:12 -0800
changeset 53664 2f4c2bc90b22
parent 53663 7870ecf291cc
child 53681 fa0d9fc371bb
8218581: Incorrect exception message generation Reviewed-by: hseigel
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: ";