1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-11-10 22:59:13 +00:00

Fix segfault in cpu_identify_all() for mono-core CPUs

Fix X0rg/CPU-X#251
Fix #176
This commit is contained in:
Xorg 2022-10-25 22:23:14 +02:00
parent 9ec39e1312
commit 1ed9a89ab0
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -1144,7 +1144,7 @@ int cpu_identify_all(struct cpu_raw_data_array_t* raw_array, struct system_id_t*
/* Update logical and physical CPU counters in system->cpu_types on the last iteration or when purpose is different than previous core */ /* Update logical and physical CPU counters in system->cpu_types on the last iteration or when purpose is different than previous core */
if (raw_array->with_affinity && (is_last_item || (is_new_cpu_type && (system->num_cpu_types > 1)))) { if (raw_array->with_affinity && (is_last_item || (is_new_cpu_type && (system->num_cpu_types > 1)))) {
cpu_type_index = is_new_cpu_type ? system->num_cpu_types - 2 : system->num_cpu_types - 1; cpu_type_index = is_new_cpu_type && !is_last_item ? system->num_cpu_types - 2 : system->num_cpu_types - 1;
copy_affinity_mask(&system->cpu_types[cpu_type_index].affinity_mask, &affinity_mask); copy_affinity_mask(&system->cpu_types[cpu_type_index].affinity_mask, &affinity_mask);
if (!is_last_item) { if (!is_last_item) {
init_affinity_mask(&affinity_mask); init_affinity_mask(&affinity_mask);