From 332f1a2a519508a6c7def7d4b645b5a3759ba13a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 5 Oct 2012 10:46:08 +0200 Subject: [PATCH] channels: Fix a memory leak in ssh_channel_select(). --- src/channels.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/channels.c b/src/channels.c index b9f5f212..0e63ef24 100644 --- a/src/channels.c +++ b/src/channels.c @@ -3046,10 +3046,14 @@ int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, break; } /* Add all channels' sessions right into an event object */ - if (!event){ + if (event == NULL) { event = ssh_event_new(); - if(!event){ - return SSH_ERROR; + if (event == NULL) { + SAFE_FREE(rchans); + SAFE_FREE(wchans); + SAFE_FREE(echans); + + return SSH_ERROR; } for (i = 0; readchans[i] != NULL; i++) { ssh_poll_get_default_ctx(readchans[i]->session);