From 1dd8abe8c75fa1281e6072c19ff25b53a7826c2c Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Sat, 28 Aug 2010 01:30:31 -0700 Subject: [PATCH] Command-line utility: avoid double free()s when modifying config option --- config-ui/browser-switchboard-config.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config-ui/browser-switchboard-config.c b/config-ui/browser-switchboard-config.c index e42c564..948952f 100644 --- a/config-ui/browser-switchboard-config.c +++ b/config-ui/browser-switchboard-config.c @@ -123,10 +123,6 @@ static int set_config_value(char *name, char *value) { i = optinfo - swb_config_options; switch (optinfo->type) { case SWB_CONFIG_OPT_STRING: - /* Free any existing string */ - if (cfg.flags & optinfo->set_mask) - free(*(char **)cfg.entries[i]); - if (strlen(value) == 0) { /* If the new value is empty, clear the config setting */ @@ -164,7 +160,11 @@ static int set_config_value(char *name, char *value) { swb_reconfig(&orig_cfg, &cfg); swb_config_free(&orig_cfg); - swb_config_free(&cfg); + /* XXX can't free all of cfg, it contains pointers to memory we just + freed above + swb_config_free(&cfg); */ + if (optinfo->type == SWB_CONFIG_OPT_STRING) + free(*(char **)cfg.entries[i]); return retval; } -- 1.7.9.5