From 5ca1271916531b05ca55290fe26be458c874c471 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 27 Aug 2012 14:34:41 +0000 Subject: [PATCH] It's not legal to free a coroutine's state structure before invoking crFinish or crFinishV, since they will attempt to write to the coroutine state variable contained in that structure. Introduced some new all-in-one macros crFinishFree and crFinishFreeV, and used those instead. Should fix today's report of a crash just after authentication. git-svn-id: svn://svn.tartarus.org/sgt/putty@9630 cda61777-01e9-0310-a592-d414129be87e --- ssh.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ssh.c b/ssh.c index a1cb34bd..ad9ccae4 100644 --- a/ssh.c +++ b/ssh.c @@ -439,6 +439,8 @@ enum { #define crState(t) crStateP(t, ssh->t) #define crFinish(z) } *crLine = 0; return (z); } #define crFinishV } *crLine = 0; return; } +#define crFinishFree(z, s) } *crLine = 0; sfree(s); return (z); } +#define crFinishFreeV(s) } *crLine = 0; sfree(s); return; } #define crReturn(z) \ do {\ *crLine =__LINE__; return (z); case __LINE__:;\ @@ -7513,8 +7515,7 @@ static void ssh2_maybe_setup_x11(struct ssh_channel *c, struct Packet *pktin, logevent("X11 forwarding refused"); } } - sfree(s); - crFinishV; + crFinishFreeV(s); } static void ssh2_maybe_setup_agent(struct ssh_channel *c, struct Packet *pktin, @@ -7545,8 +7546,7 @@ static void ssh2_maybe_setup_agent(struct ssh_channel *c, struct Packet *pktin, logevent("Agent forwarding refused"); } } - sfree(s); - crFinishV; + crFinishFreeV(s); } static void ssh2_maybe_setup_pty(struct ssh_channel *c, struct Packet *pktin, @@ -7599,8 +7599,7 @@ static void ssh2_maybe_setup_pty(struct ssh_channel *c, struct Packet *pktin, } else { ssh->editing = ssh->echoing = 1; } - sfree(s); - crFinishV; + crFinishFreeV(s); } static void ssh2_setup_env(struct ssh_channel *c, struct Packet *pktin, @@ -7663,9 +7662,8 @@ static void ssh2_setup_env(struct ssh_channel *c, struct Packet *pktin, c_write_str(ssh, "Server refused to set all environment variables\r\n"); } } -out: - sfree(s); - crFinishV; + out:; + crFinishFreeV(s); } /* -- 2.11.0