--- a/src/hotspot/share/runtime/arguments.cpp Thu Feb 21 15:17:42 2019 -0800
+++ b/src/hotspot/share/runtime/arguments.cpp Thu Feb 21 16:56:06 2019 -0800
@@ -2454,9 +2454,15 @@
(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) {