From: simon Date: Fri, 15 Jul 2011 18:30:47 +0000 (+0000) Subject: Don't delete everything under a string-subkeyed primary key by using a X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/52112bad8df0cb279c147dbeb42526aeeed07011 Don't delete everything under a string-subkeyed primary key by using a loop that fetches the next item using conf_get_str_strs and passing the previous key as a parameter, because the previous key will have been freed by the intervening conf_del_str_str. Instead, use the technique of repeatedly using conf_get_str_nthstrkey with index 0 and deleting what comes back, as PSCP and PSFTP do. Spotted by Minefield with the aid of Jacob, or possibly vice versa. git-svn-id: svn://svn.tartarus.org/sgt/putty@9220 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/settings.c b/settings.c index de69d660..934f186f 100644 --- a/settings.c +++ b/settings.c @@ -145,10 +145,8 @@ static int gppmap(void *handle, char *name, Conf *conf, int primary) /* * Start by clearing any existing subkeys of this key from conf. */ - for (val = conf_get_str_strs(conf, primary, NULL, &key); - val != NULL; - val = conf_get_str_strs(conf, primary, key, &key)) - conf_del_str_str(conf, primary, key); + while ((key = conf_get_str_nthstrkey(conf, primary, 0)) != NULL) + conf_del_str_str(conf, primary, key); /* * Now read a serialised list from the settings and unmarshal it