mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
Reviewed-by: lkorinth, hseigel, thartmann, dnsimon
This commit is contained in:
parent
0e264cfe36
commit
23ec926327
16 changed files with 80 additions and 176 deletions
|
@ -505,9 +505,6 @@ CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
|
|||
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||
size_t array_entry_count = _counters.nProcs + 1;
|
||||
_counters.cpus = NEW_C_HEAP_ARRAY(os::Linux::CPUPerfTicks, array_entry_count, mtInternal);
|
||||
if (NULL == _counters.cpus) {
|
||||
return false;
|
||||
}
|
||||
memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
|
||||
|
||||
// For the CPU load total
|
||||
|
@ -595,7 +592,7 @@ CPUPerformanceInterface::CPUPerformanceInterface() {
|
|||
|
||||
bool CPUPerformanceInterface::initialize() {
|
||||
_impl = new CPUPerformanceInterface::CPUPerformance();
|
||||
return NULL == _impl ? false : _impl->initialize();
|
||||
return _impl->initialize();
|
||||
}
|
||||
|
||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||
|
@ -748,19 +745,17 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
|||
}
|
||||
if (size > 0) {
|
||||
cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
|
||||
if (cmdline != NULL) {
|
||||
cmdline[0] = '\0';
|
||||
if (fseek(fp, 0, SEEK_SET) == 0) {
|
||||
if (fread(cmdline, 1, size, fp) == size) {
|
||||
// the file has the arguments separated by '\0',
|
||||
// so we translate '\0' to ' '
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (cmdline[i] == '\0') {
|
||||
cmdline[i] = ' ';
|
||||
}
|
||||
cmdline[0] = '\0';
|
||||
if (fseek(fp, 0, SEEK_SET) == 0) {
|
||||
if (fread(cmdline, 1, size, fp) == size) {
|
||||
// the file has the arguments separated by '\0',
|
||||
// so we translate '\0' to ' '
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (cmdline[i] == '\0') {
|
||||
cmdline[i] = ' ';
|
||||
}
|
||||
cmdline[size] = '\0';
|
||||
}
|
||||
cmdline[size] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -854,7 +849,7 @@ SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
|||
|
||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
|
||||
return NULL == _iterator ? false : _iterator->initialize();
|
||||
return _iterator->initialize();
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||
|
@ -901,7 +896,7 @@ SystemProcessInterface::SystemProcessInterface() {
|
|||
|
||||
bool SystemProcessInterface::initialize() {
|
||||
_impl = new SystemProcessInterface::SystemProcesses();
|
||||
return NULL == _impl ? false : _impl->initialize();
|
||||
return _impl->initialize();
|
||||
}
|
||||
|
||||
SystemProcessInterface::~SystemProcessInterface() {
|
||||
|
@ -916,15 +911,11 @@ CPUInformationInterface::CPUInformationInterface() {
|
|||
|
||||
bool CPUInformationInterface::initialize() {
|
||||
_cpu_info = new CPUInformation();
|
||||
if (NULL == _cpu_info) {
|
||||
return false;
|
||||
}
|
||||
_cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
|
||||
_cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
|
||||
_cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
|
||||
_cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
|
||||
_cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1029,7 @@ NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
|||
|
||||
bool NetworkPerformanceInterface::initialize() {
|
||||
_impl = new NetworkPerformanceInterface::NetworkPerformance();
|
||||
return _impl != NULL && _impl->initialize();
|
||||
return _impl->initialize();
|
||||
}
|
||||
|
||||
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue