From 967f3ab80d7be0049d22930b0d9f7e7f0caa1f1f Mon Sep 17 00:00:00 2001 From: Xorg Date: Sun, 25 Sep 2022 10:31:54 +0200 Subject: [PATCH] Improve get_cached_cpuid in case of failure --- libcpuid/libcpuid_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcpuid/libcpuid_util.c b/libcpuid/libcpuid_util.c index 6e43c53..95bd2dd 100644 --- a/libcpuid/libcpuid_util.c +++ b/libcpuid/libcpuid_util.c @@ -217,8 +217,11 @@ struct cpu_id_t* get_cached_cpuid(void) static int initialized = 0; static struct cpu_id_t id; if (initialized) return &id; - if (cpu_identify(NULL, &id)) + if (cpu_identify(NULL, &id) != ERR_OK) { memset(&id, 0, sizeof(id)); + id.architecture = ARCHITECTURE_UNKNOWN; + id.vendor = VENDOR_UNKNOWN; + } initialized = 1; return &id; }