print_cpu_temperature: fix memory leak (Thanks kuba)

This commit is contained in:
Michael Stapelberg 2013-10-24 19:19:21 +02:00
parent c6e9fc84c6
commit ebfafc5dac

View 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);