Fix a memory leak in ssh1_channel_close_local.

Leak Sanitiser was kind enough to point this out to me during testing
of the port forwarding rework: chan_log_close_msg() returns a
dynamically allocated char *, which the caller is supposed to free.
This commit is contained in:
Simon Tatham 2020-01-27 19:40:58 +00:00
Родитель 2160205aee
Коммит 22350d7668
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -520,10 +520,12 @@ static void ssh1_channel_close_local(struct ssh1_channel *c,
{
struct ssh1_connection_state *s = c->connlayer;
PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */
const char *msg = chan_log_close_msg(c->chan);
char *msg = chan_log_close_msg(c->chan);
if (msg != NULL)
if (msg != NULL) {
ppl_logevent("%s%s%s", msg, reason ? " " : "", reason ? reason : "");
sfree(msg);
}
chan_free(c->chan);
c->chan = zombiechan_new();