]> git.sur5r.net Git - i3/i3status/commitdiff
print_cpu_temperature: fix memory leak (Thanks kuba)
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 24 Oct 2013 17:19:21 +0000 (19:19 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 24 Oct 2013 17:19:21 +0000 (19:19 +0200)
src/print_cpu_temperature.c

index 8bd39a47417076f079957a73d1dfdc111b53d316..6b8aa5969a314ce27346b2587f879bf6085bfa1f 100644 (file)
@@ -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);