aboutsummaryrefslogtreecommitdiff
path: root/src/messages.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-04-02 16:13:20 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-04-02 16:13:20 +0200
commit5236358a48c28710545f86ab3c4c346bb05140e8 (patch)
tree8f060f7c6b2b4a0256919ae229f7c21cb62b19b5 /src/messages.c
parentd6fe9dc22023a389123e242ec4942f38bbfadfba (diff)
downloadlibssh-5236358a48c28710545f86ab3c4c346bb05140e8.tar.gz
libssh-5236358a48c28710545f86ab3c4c346bb05140e8.tar.xz
libssh-5236358a48c28710545f86ab3c4c346bb05140e8.zip
messages: Don't leak memory after callback execution
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/messages.c')
-rw-r--r--src/messages.c19
1 files changed, 19 insertions, 0 deletions
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);