diff options
author | Benny Baumann <BenBE@geshi.org> | 2023-07-28 12:31:27 +0200 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2023-07-28 12:31:27 +0200 |
commit | 84f10749f37ceadba88527607b20e83110791e6d (patch) | |
tree | 5142584c8cc4866f9ac9feb5ac49c8f709f4a9aa /linux | |
parent | ea23eee8e224b5ec0b0fb832aa0c59d2e90d096b (diff) |
Avoid VLA in LibSensors code
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LibSensors.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/linux/LibSensors.c b/linux/LibSensors.c index ff084b64..392638df 100644 --- a/linux/LibSensors.c +++ b/linux/LibSensors.c @@ -143,7 +143,8 @@ static int tempDriverPriority(const sensors_chip_name* chip) { void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, unsigned int activeCPUs) { assert(existingCPUs > 0 && existingCPUs < 16384); - double data[existingCPUs + 1]; + + double* data = xMallocArray(existingCPUs + 1, sizeof(double)); for (size_t i = 0; i < existingCPUs + 1; i++) data[i] = NAN; @@ -264,6 +265,8 @@ void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, uns out: for (unsigned int i = 0; i <= existingCPUs; i++) cpus[i].temperature = data[i]; + + free(data); } #endif /* HAVE_SENSORS_SENSORS_H */ |