]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Don't delete everything under a string-subkeyed primary key by using a
authorSimon Tatham <anakin@pobox.com>
Fri, 15 Jul 2011 18:30:47 +0000 (18:30 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 15 Jul 2011 18:30:47 +0000 (18:30 +0000)
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.

[originally from svn r9220]

settings.c

index de69d66090ab38c5d32282bf012ee713b4d9ece0..934f186f43efe525200e9510699571c396c3f757 100644 (file)
@@ -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