changeset 52891:e1fcdc7ead4d

8214707: Prevent GCC 8 from reporting error in ClassLoader::file_name_for_class_name() Reviewed-by: hseigel, dholmes
author dchuyko
date Fri, 07 Dec 2018 10:48:39 +0300
parents b0e751c70385
children 442d322bb6d8
files src/hotspot/share/classfile/classLoader.cpp
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classLoader.cpp	Thu Dec 06 22:05:31 2018 -0800
+++ b/src/hotspot/share/classfile/classLoader.cpp	Fri Dec 07 10:48:39 2018 +0300
@@ -1224,13 +1224,14 @@
   assert((int)strlen(class_name) == class_name_len, "invariant");
 
   static const char class_suffix[] = ".class";
+  size_t class_suffix_len = sizeof(class_suffix);
 
   char* const file_name = NEW_RESOURCE_ARRAY(char,
                                              class_name_len +
-                                             sizeof(class_suffix)); // includes term NULL
+                                             class_suffix_len); // includes term NULL
 
   strncpy(file_name, class_name, class_name_len);
-  strncpy(&file_name[class_name_len], class_suffix, sizeof(class_suffix));
+  strncpy(&file_name[class_name_len], class_suffix, class_suffix_len);
 
   return file_name;
 }