diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-08-11 09:41:07 +0200 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-08-11 09:41:07 +0200 |
commit | 3da1c17acbc37a2b54eb084fcd8030cde0cf723b (patch) | |
tree | 4690f1d82b574a5f3112171407cad7ef007d7f0b /libssh/scp.c | |
parent | 7e9f0803c52bba4149c0eb1aa52ef3933c95f657 (diff) | |
download | libssh-3da1c17acbc37a2b54eb084fcd8030cde0cf723b.tar.gz libssh-3da1c17acbc37a2b54eb084fcd8030cde0cf723b.tar.xz libssh-3da1c17acbc37a2b54eb084fcd8030cde0cf723b.zip |
Add a NULL check for strdup memory allocation.
Diffstat (limited to 'libssh/scp.c')
-rw-r--r-- | libssh/scp.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libssh/scp.c b/libssh/scp.c index 878b6cb..03a7012 100644 --- a/libssh/scp.c +++ b/libssh/scp.c @@ -43,9 +43,14 @@ ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location){ ssh_scp_free(scp); return NULL; } + scp->location=strdup(location); + if (scp->location == NULL) { + ssh_set_error(session,SSH_FATAL,"Error allocating memory for ssh_scp"); + ssh_scp_free(scp); + return NULL; + } scp->session=session; scp->mode=mode; - scp->location=strdup(location); scp->channel=NULL; scp->state=SSH_SCP_NEW; return scp; |