aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorOliver Stöneberg <oliverst@online.de>2011-04-26 15:56:00 -0700
committerAndreas Schneider <asn@cryptomilk.org>2011-05-01 19:33:09 +0200
commitc3849a3cfd4bb298c255c41bf2cbc5592e893d17 (patch)
tree715999f4e4280012e3ee3d189caed0e2e1d82389 /examples
parent91c9d86d4597ae5b3da40a33b1ba33c98066d573 (diff)
downloadlibssh-c3849a3cfd4bb298c255c41bf2cbc5592e893d17.tar.gz
libssh-c3849a3cfd4bb298c255c41bf2cbc5592e893d17.tar.xz
libssh-c3849a3cfd4bb298c255c41bf2cbc5592e893d17.zip
examples: Fixed memory leak in samplessh when using commands.
Diffstat (limited to 'examples')
-rw-r--r--examples/sample.c5
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)){