From e3eec3f62ad4cf125d45dc681368710f20e789d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 14 Sep 2025 17:56:56 +0800 Subject: [PATCH] CPU (Windows): handles zero temperature data and refactors value use Fixes #1960 --- src/detection/cpu/cpu_windows.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 79ed7a660..d5c7f843f 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -102,12 +102,16 @@ const char* detectThermalTemp(double* result) if (pCounterData->dwDataSize == sizeof(int32_t)) { DWORD* pCounterIds = (DWORD*)(pMultiCounters + 1); + int32_t value = *(int32_t*)(pCounterData + 1); + if (value == 0) + return "Temperature data is zero"; + switch (pCounterIds[iCounter]) { case 0: // Temperature - *result = *(int32_t*)(pCounterData + 1) - 273; + *result = value - 273; break; case 3: // High Precision Temperature - *result = *(int32_t*)(pCounterData + 1) / 10.0 - 273; + *result = value / 10.0 - 273; break; } }