1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-09 23:28:06 -05:00

Change order of cleanup in delete_inst.

If you close a session window with an associated SSH back end, the
back end may call back to notify_remote_exit() from ssh_free(), which
queues a new top-level callback citing the inst structure we were
about to delete.

We could fix this by introducing a special 'moribund' flag which
inhibits notify_remote_exit from queueing a callback, but far easier
is to move the delete_callbacks_for_context() call to _after_ all
subsidiary things have been cleaned up, so that any last-minute
callbacks they might schedule will be promptly unscheduled again
before they do any damage.
This commit is contained in:
Simon Tatham 2017-11-26 15:35:25 +00:00
parent 199f381aa9
commit f212e2cbea

View File

@ -2039,7 +2039,6 @@ void notify_remote_exit(void *frontend)
static void delete_inst(struct gui_data *inst)
{
delete_callbacks_for_context(inst);
if (inst->reconfigure_dialog) {
gtk_widget_destroy(inst->reconfigure_dialog);
inst->reconfigure_dialog = NULL;
@ -2077,6 +2076,17 @@ static void delete_inst(struct gui_data *inst)
log_free(inst->logctx);
inst->logctx = NULL;
}
/*
* Delete any top-level callbacks associated with inst, which
* would otherwise become stale-pointer dereferences waiting to
* happen. We do this last, because some of the above cleanups
* (notably shutting down the backend) might themelves queue such
* callbacks, so we need to make sure they don't do that _after_
* we're supposed to have cleaned everything up.
*/
delete_callbacks_for_context(inst);
sfree(inst);
}