diff options
author | Oliver Stöneberg <oliverst@online.de> | 2011-04-26 15:56:00 -0700 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-05-01 19:42:01 +0200 |
commit | 2431c7d9250882f83a3b3ce97b7cb0dd04c48344 (patch) | |
tree | 0275d20034e96be820fa14885dfd384dd0b05dc0 | |
parent | fc9c61714f4fc509320843bd0edd1cddbdd6943d (diff) | |
download | libssh-2431c7d9250882f83a3b3ce97b7cb0dd04c48344.tar.gz libssh-2431c7d9250882f83a3b3ce97b7cb0dd04c48344.tar.xz libssh-2431c7d9250882f83a3b3ce97b7cb0dd04c48344.zip |
examples: Fixed memory leak in samplessh when using commands.
(cherry picked from commit c3849a3cfd4bb298c255c41bf2cbc5592e893d17)
-rw-r--r-- | examples/sample.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/sample.c b/examples/sample.c index c7fec6c8..547fd184 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -431,8 +431,11 @@ static void batch_shell(ssh_session session){ ssh_channel channel; char buffer[1024]; int i,s=0; - for(i=0;i<MAXCMD && cmds[i];++i) + for(i=0;i<MAXCMD && cmds[i];++i) { s+=snprintf(buffer+s,sizeof(buffer)-s,"%s ",cmds[i]); + free(cmds[i]); + cmds[i] = NULL; + } channel=ssh_channel_new(session); ssh_channel_open_session(channel); if(ssh_channel_request_exec(channel,buffer)){ |