From 580becd20bfa7a3e2d591eda9a9600f6572fb81e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 21 Oct 2007 14:28:14 +0000 Subject: [PATCH] Fix a memory leak on library initialization error. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4972 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 2 +- prog/sensors/main.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 37dbc844..472e63d9 100644 --- a/CHANGES +++ b/CHANGES @@ -31,7 +31,7 @@ SVN HEAD Add w83793 support Log the error code on failure Add lm87 support - Program sensors: Fix a memory leak on error (with -u) + Program sensors: Fix a memory leaks on error Add sch311x support Hide error on missing dme1737 fan and pwm Add thmc50/adm1022 support diff --git a/prog/sensors/main.c b/prog/sensors/main.c index b1a7daa5..e3031ab7 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -229,16 +229,18 @@ int main (int argc, char *argv[]) } open_config_file(config_file_name); - if ((res = sensors_init(config_file))) { + res = sensors_init(config_file); + close_config_file(config_file_name); + if (res) { fprintf(stderr,"%s\n",sensors_strerror(res)); if (res == -SENSORS_ERR_PROC) fprintf(stderr, "Kernel interface access error\n" "For 2.6 kernels, make sure you have mounted sysfs and libsensors\n" "was compiled with sysfs support!\n"); + sensors_cleanup(); exit(1); } - close_config_file(config_file_name); /* build the degrees string */ set_degstr();