Fix a couple of code paths on which, if fxp_readdir returned an error,
[sgt/putty] / config.c
index a7236d1..b0b0092 100644 (file)
--- a/config.c
+++ b/config.c
@@ -131,12 +131,11 @@ void conf_filesel_handler(union control *ctrl, void *dlg,
     Conf *conf = (Conf *)data;
 
     if (event == EVENT_REFRESH) {
-       dlg_filesel_set(ctrl, dlg, *conf_get_filename(conf, key));
+       dlg_filesel_set(ctrl, dlg, conf_get_filename(conf, key));
     } else if (event == EVENT_VALCHANGE) {
-       Filename filename;
-       dlg_filesel_get(ctrl, dlg, &filename);
-       conf_set_filename(conf, key, &filename);
-       /* If Filenames ever become dynamic, free this one. */
+       Filename *filename = dlg_filesel_get(ctrl, dlg);
+       conf_set_filename(conf, key, filename);
+        filename_free(filename);
     }
 }
 
@@ -530,12 +529,19 @@ static void sshbug_handler(union control *ctrl, void *dlg,
 {
     Conf *conf = (Conf *)data;
     if (event == EVENT_REFRESH) {
+        /*
+         * We must fetch the previously configured value from the Conf
+         * before we start modifying the drop-down list, otherwise the
+         * spurious SELCHANGE we trigger in the process will overwrite
+         * the value we wanted to keep.
+         */
+        int oldconf = conf_get_int(conf, ctrl->listbox.context.i);
        dlg_update_start(ctrl, dlg);
        dlg_listbox_clear(ctrl, dlg);
        dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO);
        dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF);
        dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON);
-       switch (conf_get_int(conf, ctrl->listbox.context.i)) {
+       switch (oldconf) {
          case AUTO:      dlg_listbox_select(ctrl, dlg, 0); break;
          case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break;
          case FORCE_ON:  dlg_listbox_select(ctrl, dlg, 2); break;
@@ -848,8 +854,8 @@ static void colour_handler(union control *ctrl, void *dlg,
            } else {
                clear = FALSE;
                r = conf_get_int_int(conf, CONF_colours, i*3+0);
-               g = conf_get_int_int(conf, CONF_colours, i*3+0);
-               b = conf_get_int_int(conf, CONF_colours, i*3+0);
+               g = conf_get_int_int(conf, CONF_colours, i*3+1);
+               b = conf_get_int_int(conf, CONF_colours, i*3+2);
            }
            update = TRUE;
        }
@@ -902,8 +908,8 @@ static void colour_handler(union control *ctrl, void *dlg,
             */
            if (dlg_coloursel_results(ctrl, dlg, &r, &g, &b)) {
                conf_set_int_int(conf, CONF_colours, i*3+0, r);
-               conf_set_int_int(conf, CONF_colours, i*3+0, g);
-               conf_set_int_int(conf, CONF_colours, i*3+0, b);
+               conf_set_int_int(conf, CONF_colours, i*3+1, g);
+               conf_set_int_int(conf, CONF_colours, i*3+2, b);
                clear = FALSE;
                update = TRUE;
            }
@@ -1129,9 +1135,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
     } else if (event == EVENT_ACTION) {
        if (ctrl == pfd->addbutton) {
            char *family, *type, *src, *key, *val;
-           int i, whichbutton;
+           int whichbutton;
 
-           i = 0;
 #ifndef NO_IPV6
            whichbutton = dlg_radiobutton_get(pfd->addressfamily, dlg);
            if (whichbutton == 1)
@@ -1791,9 +1796,13 @@ void setup_config_box(struct controlbox *b, int midsession,
     ctrl_checkbox(s, "Allow terminal to use xterm 256-colour mode", '2',
                  HELPCTX(colours_xterm256), conf_checkbox_handler,
                  I(CONF_xterm_256_colour));
-    ctrl_checkbox(s, "Bolded text is a different colour", 'b',
-                 HELPCTX(colours_bold),
-                 conf_checkbox_handler, I(CONF_bold_colour));
+    ctrl_radiobuttons(s, "Indicate bolded text by changing:", 'b', 3,
+                      HELPCTX(colours_bold),
+                      conf_radiobutton_handler, I(CONF_bold_style),
+                      "The font", I(1),
+                      "The colour", I(2),
+                      "Both", I(3),
+                      NULL);
 
     str = dupprintf("Adjust the precise colours %s displays", appname);
     s = ctrl_getset(b, "Window/Colours", "adjust", str);
@@ -2448,6 +2457,9 @@ void setup_config_box(struct controlbox *b, int midsession,
            ctrl_droplist(s, "Chokes on SSH-2 ignore messages", '2', 20,
                          HELPCTX(ssh_bugs_ignore2),
                          sshbug_handler, I(CONF_sshbug_ignore2));
+           ctrl_droplist(s, "Chokes on PuTTY's SSH-2 'winadj' requests", 'j',
+                          20, HELPCTX(ssh_bugs_winadj),
+                         sshbug_handler, I(CONF_sshbug_winadj));
            ctrl_droplist(s, "Miscomputes SSH-2 HMAC keys", 'm', 20,
                          HELPCTX(ssh_bugs_hmac2),
                          sshbug_handler, I(CONF_sshbug_hmac2));