Skip to content

Commit e3eec3f

Browse files
committed
CPU (Windows): handles zero temperature data and refactors value use
Fixes #1960
1 parent e025f28 commit e3eec3f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/detection/cpu/cpu_windows.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ const char* detectThermalTemp(double* result)
102102
if (pCounterData->dwDataSize == sizeof(int32_t))
103103
{
104104
DWORD* pCounterIds = (DWORD*)(pMultiCounters + 1);
105+
int32_t value = *(int32_t*)(pCounterData + 1);
106+
if (value == 0)
107+
return "Temperature data is zero";
108+
105109
switch (pCounterIds[iCounter]) {
106110
case 0: // Temperature
107-
*result = *(int32_t*)(pCounterData + 1) - 273;
111+
*result = value - 273;
108112
break;
109113
case 3: // High Precision Temperature
110-
*result = *(int32_t*)(pCounterData + 1) / 10.0 - 273;
114+
*result = value / 10.0 - 273;
111115
break;
112116
}
113117
}

0 commit comments

Comments
 (0)