X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/a4e8ffb05a796a1488598fbae9e2dcd54d0313bc..56b9b9a752e89913fa19001ab85dffa7f95ef307:/config.c diff --git a/config.c b/config.c index 184023d0..e8b7c579 100644 --- a/config.c +++ b/config.c @@ -256,8 +256,12 @@ static void sessionsaver_handler(union control *ctrl, void *dlg, * allocate space to store the current contents of the saved * session edit box (since it must persist even when we switch * panels, but is not part of the Config). + * + * Of course, this doesn't need to be done mid-session. */ - if (!dlg_get_privdata(ssd->editbox, dlg)) { + if (!ssd->editbox) { + savedsession = NULL; + } else if (!dlg_get_privdata(ssd->editbox, dlg)) { savedsession = (char *) dlg_alloc_privdata(ssd->editbox, dlg, SAVEDSESSION_LEN); savedsession[0] = '\0'; @@ -333,6 +337,11 @@ static void sessionsaver_handler(union control *ctrl, void *dlg, dlg_refresh(ssd->listbox, dlg); } } else if (ctrl == ssd->okbutton) { + if (!savedsession) { + /* In a mid-session Change Settings, Apply is always OK. */ + dlg_end(dlg, 1); + return; + } /* * Annoying special case. If the `Open' button is * pressed while no host name is currently set, _and_ @@ -730,6 +739,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, ssd = (struct sessionsaver_data *) ctrl_alloc(b, sizeof(struct sessionsaver_data)); + memset(ssd, 0, sizeof(*ssd)); ssd->sesslist = (midsession ? NULL : sesslist); /*