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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -861,11 +861,7 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() {
char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const {
if (str != NULL) {
size_t len = strlen(str);
char* tmp = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
strncpy(tmp, str, len);
tmp[len] = '\0';
return tmp;
return os::strdup_check_oom(str, mtInternal);
}
return NULL;
}