From f72f96eda6dc9a8a910d931e11260e882c5daeb9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 23 Feb 2012 10:23:27 +0100 Subject: [PATCH] sensors plugin: Fix memory leak in configuration; enhance comments. Change-Id: Ic4f9d2aae1aec9fbd83307fe3bb7d476f49f6827 --- src/sensors.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sensors.c b/src/sensors.c index 96a54fca..7c1566c3 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -227,12 +227,17 @@ static int sensors_config (const char *key, const char *value) if (sensor_list == NULL) sensor_list = ignorelist_create (1); + /* TODO: This setting exists for compatibility with old versions of + * lm-sensors. Remove support for those ancient versions in the next + * major release. */ if (strcasecmp (key, "SensorConfigFile") == 0) { - /* we will leak memory here if SensorConfigFile is - used more than once, maybe we can just drop support - for broken, extremely ancient libsensors? */ - conffile = strdup (value); + char *tmp = strdup (value); + if (tmp != NULL) + { + sfree (conffile); + conffile = tmp; + } } else if (strcasecmp (key, "Sensor") == 0) { -- 2.30.2