# HG changeset patch # User dchuyko # Date 1544168919 -10800 # Node ID e1fcdc7ead4d036daf20a0b0e2a8e4363397cd0f # Parent b0e751c7038566d997fca9428fa13fc4cc1a0ac4 8214707: Prevent GCC 8 from reporting error in ClassLoader::file_name_for_class_name() Reviewed-by: hseigel, dholmes diff -r b0e751c70385 -r e1fcdc7ead4d src/hotspot/share/classfile/classLoader.cpp --- 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; }