From: Florian Forster Date: Thu, 23 Feb 2012 09:23:27 +0000 (+0100) Subject: sensors plugin: Fix memory leak in configuration; enhance comments. X-Git-Tag: collectd-5.1.0~27^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f72f96eda6dc9a8a910d931e11260e882c5daeb9;p=collectd.git sensors plugin: Fix memory leak in configuration; enhance comments. Change-Id: Ic4f9d2aae1aec9fbd83307fe3bb7d476f49f6827 --- 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) {