From ebfafc5dac9cb15ec4ec9b13e9b933c9c2c5d5c9 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 24 Oct 2013 19:19:21 +0200 Subject: print_cpu_temperature: fix memory leak (Thanks kuba) --- src/print_cpu_temperature.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c index 8bd39a4..6b8aa59 100644 --- a/src/print_cpu_temperature.c +++ b/src/print_cpu_temperature.c @@ -50,10 +50,12 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const const char *walk; bool colorful_output = false; - if (path == NULL) - asprintf(&thermal_zone, THERMAL_ZONE, zone); - else - asprintf(&thermal_zone, path, zone); + if (thermal_zone == NULL) { + if (path == NULL) + asprintf(&thermal_zone, THERMAL_ZONE, zone); + else + asprintf(&thermal_zone, path, zone); + } path = thermal_zone; INSTANCE(path); -- cgit v1.2.3