8214777: Avoid some GCC 8.X strncpy() errors in HotSpot

Reviewed-by: kbarrett, rehn
This commit is contained in:
Mikael Vidstedt 2019-02-21 16:56:06 -08:00
parent 46666a2d94
commit 15d554b395
12 changed files with 59 additions and 73 deletions

View file

@ -2454,9 +2454,15 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
(is_absolute_path = match_option(option, "-agentpath:", &tail))) {
if(tail != NULL) {
const char* pos = strchr(tail, '=');
size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtArguments), tail, len);
name[len] = '\0';
char* name;
if (pos == NULL) {
name = os::strdup_check_oom(tail, mtArguments);
} else {
size_t len = pos - tail;
name = NEW_C_HEAP_ARRAY(char, len + 1, mtArguments);
memcpy(name, tail, len);
name[len] = '\0';
}
char *options = NULL;
if(pos != NULL) {