From 1ed9a89ab04e3c029f8f6f5c855e90e676fb7d0d Mon Sep 17 00:00:00 2001 From: Xorg Date: Tue, 25 Oct 2022 22:23:14 +0200 Subject: [PATCH] Fix segfault in cpu_identify_all() for mono-core CPUs Fix X0rg/CPU-X#251 Fix #176 --- libcpuid/cpuid_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpuid/cpuid_main.c b/libcpuid/cpuid_main.c index bc7e450..ee349c6 100644 --- a/libcpuid/cpuid_main.c +++ b/libcpuid/cpuid_main.c @@ -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 */ 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); if (!is_last_item) { init_affinity_mask(&affinity_mask);