]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Clearing and refilling the code-pages list box can cause a
authorSimon Tatham <anakin@pobox.com>
Wed, 10 Jun 2009 17:42:15 +0000 (17:42 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 10 Jun 2009 17:42:15 +0000 (17:42 +0000)
re-entrant call to its handler in config.c, which destroys the
previous value in cfg->line_codepage. Therefore, preserve the right
value in an automatic variable until all the re-entrant calls have
finished.

[originally from svn r8592]

config.c

index 8d492df1636f7a0ad792f5a6443abb4810a672b4..3f0ea9317a83e495e45b479fbb59fb1b0ebb657a 100644 (file)
--- a/config.c
+++ b/config.c
@@ -317,14 +317,14 @@ static void codepage_handler(union control *ctrl, void *dlg,
     Config *cfg = (Config *)data;
     if (event == EVENT_REFRESH) {
        int i;
-       const char *cp;
+       const char *cp, *thiscp;
        dlg_update_start(ctrl, dlg);
-       strcpy(cfg->line_codepage,
-              cp_name(decode_codepage(cfg->line_codepage)));
+       thiscp = cp_name(decode_codepage(cfg->line_codepage));
        dlg_listbox_clear(ctrl, dlg);
        for (i = 0; (cp = cp_enumerate(i)) != NULL; i++)
            dlg_listbox_add(ctrl, dlg, cp);
-       dlg_editbox_set(ctrl, dlg, cfg->line_codepage);
+       dlg_editbox_set(ctrl, dlg, thiscp);
+       strcpy(cfg->line_codepage, thiscp);
        dlg_update_done(ctrl, dlg);
     } else if (event == EVENT_VALCHANGE) {
        dlg_editbox_get(ctrl, dlg, cfg->line_codepage,