From e5b1301f208d9f1220b0d3de35e3283e1be177e0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 16 Dec 2014 19:25:11 +0000 Subject: [PATCH] -fix leak --- .../gnunet-service-sensordashboard.c | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/sensordashboard/gnunet-service-sensordashboard.c b/src/sensordashboard/gnunet-service-sensordashboard.c index cfccc9368..6506aa2dc 100644 --- a/src/sensordashboard/gnunet-service-sensordashboard.c +++ b/src/sensordashboard/gnunet-service-sensordashboard.c @@ -673,9 +673,14 @@ create_full_sensor_msg (char *sensorname) sensor = GNUNET_CONTAINER_multihashmap_get (sensors, &key); if (NULL == sensor) return NULL; - GNUNET_asprintf (&sensor_path, "%s%s", sensor_dir, sensorname); + GNUNET_asprintf (&sensor_path, + "%s%s", + sensor_dir, + sensorname); if (GNUNET_OK != - GNUNET_DISK_file_size (sensor_path, &sensorfile_size, GNUNET_NO, + GNUNET_DISK_file_size (sensor_path, + &sensorfile_size, + GNUNET_NO, GNUNET_YES)) { GNUNET_free (sensor_dir); @@ -683,19 +688,24 @@ create_full_sensor_msg (char *sensorname) return NULL; } sensorname_size = strlen (sensorname) + 1; + sensorscript_path = NULL; sensorscript_size = 0; sensorscriptname_size = 0; /* Test if there is an associated script */ if (NULL != sensor->ext_process) { - GNUNET_asprintf (&sensorscript_path, "%s%s-files%s%s", sensor_dir, - sensor->name, DIR_SEPARATOR_STR, sensor->ext_process); + GNUNET_asprintf (&sensorscript_path, + "%s%s-files%s%s", + sensor_dir, + sensor->name, + DIR_SEPARATOR_STR, + sensor->ext_process); if (GNUNET_OK == - GNUNET_DISK_file_size (sensorscript_path, &sensorscript_size, GNUNET_NO, + GNUNET_DISK_file_size (sensorscript_path, + &sensorscript_size, + GNUNET_NO, GNUNET_YES)) - { sensorscriptname_size = strlen (sensor->ext_process) + 1; - } } /* Construct the msg */ total_size = @@ -718,8 +728,8 @@ create_full_sensor_msg (char *sensorname) memcpy (dummy, sensor->ext_process, sensorscriptname_size); dummy += sensorscriptname_size; GNUNET_DISK_fn_read (sensorscript_path, dummy, sensorscript_size); - GNUNET_free (sensorscript_path); } + GNUNET_free_non_null (sensorscript_path); GNUNET_free (sensor_path); return msg; } -- 2.25.1