From 74eda959ddf653b7d20779d84f0a140e85376726 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Tue, 29 May 2018 10:37:18 +0200 Subject: [PATCH] turbostat plugin: free the right variable scan-build: Using '/usr/bin/clang-6.0' for static analysis make all-am make[1]: Entering directory '/home/ruben/src/collectd' CC src/turbostat.lo src/turbostat.c:1292:5: warning: Argument to free() is the address of the global variable 'thread_delta', which is not memory allocated by malloc() sfree(threads); ^~~~~~~~~~~~~~ ./src/daemon/common.h:41:5: note: expanded from macro 'sfree' free(ptr); \ ^~~~~~~~~ src/turbostat.c:1299:5: warning: Argument to free() is the address of the global variable 'core_delta', which is not memory allocated by malloc() sfree(cores); ^~~~~~~~~~~~ ./src/daemon/common.h:41:5: note: expanded from macro 'sfree' free(ptr); \ ^~~~~~~~~ 2 warnings generated. CCLD turbostat.la --- src/turbostat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/turbostat.c b/src/turbostat.c index 2bc7e3f1..68cf4120 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -1289,15 +1289,15 @@ static int allocate_counters(struct thread_data **threads, *cores = calloc(total_cores, sizeof(struct core_data)); if (*cores == NULL) { ERROR("turbostat plugin: calloc failed"); - sfree(threads); + sfree(*threads); return -1; } *packages = calloc(topology.num_packages, sizeof(struct pkg_data)); if (*packages == NULL) { ERROR("turbostat plugin: calloc failed"); - sfree(cores); - sfree(threads); + sfree(*cores); + sfree(*threads); return -1; } -- 2.11.0