[PATCH 2/5] Fixed some memory leaks related to subsurface_get_conf()
Lubomir I. Ivanov
neolit123 at gmail.com
Sun Dec 16 14:26:35 PST 2012
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
In gtk-gui.c:init() we retrieve the configuration values
for PO2, PN2, PHE thresholds but have to also free the values
once done parsing with sscanf().
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
gtk-gui.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gtk-gui.c b/gtk-gui.c
index 834d199..2731f4f 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1170,14 +1170,20 @@ void init_ui(int *argcp, char ***argvp)
prefs.pp_graphs.pn2 = PTR_TO_BOOL(subsurface_get_conf("pn2graph", PREF_BOOL));
prefs.pp_graphs.phe = PTR_TO_BOOL(subsurface_get_conf("phegraph", PREF_BOOL));
conf_value = subsurface_get_conf("po2threshold", PREF_STRING);
- if (conf_value)
+ if (conf_value) {
sscanf(conf_value, "%lf", &prefs.pp_graphs.po2_threshold);
+ free((void *)conf_value);
+ }
conf_value = subsurface_get_conf("pn2threshold", PREF_STRING);
- if (conf_value)
+ if (conf_value) {
sscanf(conf_value, "%lf", &prefs.pp_graphs.pn2_threshold);
+ free((void *)conf_value);
+ }
conf_value = subsurface_get_conf("phethreshold", PREF_STRING);
- if (conf_value)
+ if (conf_value) {
sscanf(conf_value, "%lf", &prefs.pp_graphs.phe_threshold);
+ free((void *)conf_value);
+ }
prefs.profile_red_ceiling = PTR_TO_BOOL(subsurface_get_conf("redceiling", PREF_BOOL));
divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
autogroup = PTR_TO_BOOL(subsurface_get_conf("autogroup", PREF_BOOL));
--
1.7.11.msysgit.0
More information about the subsurface
mailing list