changeset 54153:2f4c2bc90b22

8218581: Incorrect exception message generation Reviewed-by: hseigel
author mikael
date Wed, 06 Feb 2019 18:34:12 -0800
parents 7870ecf291cc
children fa0d9fc371bb
files src/hotspot/share/classfile/modules.cpp
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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: ";