From 5236358a48c28710545f86ab3c4c346bb05140e8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 2 Apr 2015 16:13:20 +0200 Subject: [PATCH] messages: Don't leak memory after callback execution Signed-off-by: Andreas Schneider --- src/messages.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/messages.c b/src/messages.c index 5a6963e8..d906e696 100644 --- a/src/messages.c +++ b/src/messages.c @@ -524,6 +524,25 @@ void ssh_message_free(ssh_message msg){ SAFE_FREE(msg->channel_request.var_value); SAFE_FREE(msg->channel_request.command); SAFE_FREE(msg->channel_request.subsystem); + switch (msg->channel_request.type) { + case SSH_CHANNEL_REQUEST_EXEC: + SAFE_FREE(msg->channel_request.command); + break; + case SSH_CHANNEL_REQUEST_ENV: + SAFE_FREE(msg->channel_request.var_name); + SAFE_FREE(msg->channel_request.var_value); + break; + case SSH_CHANNEL_REQUEST_PTY: + SAFE_FREE(msg->channel_request.TERM); + break; + case SSH_CHANNEL_REQUEST_SUBSYSTEM: + SAFE_FREE(msg->channel_request.subsystem); + break; + case SSH_CHANNEL_REQUEST_X11: + SAFE_FREE(msg->channel_request.x11_auth_protocol); + SAFE_FREE(msg->channel_request.x11_auth_cookie); + break; + } break; case SSH_REQUEST_SERVICE: SAFE_FREE(msg->service_request.service);