projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
write_riemann plugin: Fix a memory leak.
[collectd.git]
/
src
/
sensors.c
diff --git
a/src/sensors.c
b/src/sensors.c
index
96a54fc
..
209482e
100644
(file)
--- a/
src/sensors.c
+++ b/
src/sensors.c
@@
-153,7
+153,7
@@
typedef struct featurelist
# ifndef SENSORS_CONF_PATH
# define SENSORS_CONF_PATH "/etc/sensors.conf"
# endif
# ifndef SENSORS_CONF_PATH
# define SENSORS_CONF_PATH "/etc/sensors.conf"
# endif
-static c
onst c
har *conffile = SENSORS_CONF_PATH;
+static char *conffile = SENSORS_CONF_PATH;
/* #endif SENSORS_API_VERSION < 0x400 */
#elif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
/* #endif SENSORS_API_VERSION < 0x400 */
#elif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
@@
-165,7
+165,7
@@
typedef struct featurelist
struct featurelist *next;
} featurelist_t;
struct featurelist *next;
} featurelist_t;
-static c
onst c
har *conffile = NULL;
+static char *conffile = NULL;
/* #endif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */
#else /* if SENSORS_API_VERSION >= 0x500 */
/* #endif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */
#else /* if SENSORS_API_VERSION >= 0x500 */
@@
-227,12
+227,17
@@
static int sensors_config (const char *key, const char *value)
if (sensor_list == NULL)
sensor_list = ignorelist_create (1);
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)
{
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)
{
}
else if (strcasecmp (key, "Sensor") == 0)
{
@@
-292,7
+297,7
@@
static int sensors_load_conf (void)
call_once = 1;
call_once = 1;
- if (conffile)
+ if (conffile
!= NULL
)
{
fh = fopen (conffile, "r");
if (fh == NULL)
{
fh = fopen (conffile, "r");
if (fh == NULL)