summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-09 16:01:29 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-09 16:01:29 +0200
commit81be2f467ce679e5e1a4b650ebdfc15ce3a9deb7 (patch)
treebf1aa343f10b5704c1cf5f186ae2deb06fa3caeb
parent2785544fb51ec0ee439510f070f769fe66ccfdc7 (diff)
downloadlibgit2-81be2f467ce679e5e1a4b650ebdfc15ce3a9deb7.tar.gz
ssh: move NULL check to the free function
Let `ssh_stream_free()` take a NULL stream, as free functions should, and remove the check from the connection setup. The connection setup would not need the check anyhow, as we always have a stream by the time we reach this code.
-rw-r--r--src/transports/ssh.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 5c8545fe1..83af137f8 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -177,11 +177,12 @@ static int ssh_stream_write(
static void ssh_stream_free(git_smart_subtransport_stream *stream)
{
ssh_stream *s = (ssh_stream *)stream;
- ssh_subtransport *t = OWNING_SUBTRANSPORT(s);
- int ret;
+ ssh_subtransport *t;
- GIT_UNUSED(ret);
+ if (!stream)
+ return;
+ t = OWNING_SUBTRANSPORT(s);
t->current_stream = NULL;
if (s->channel) {
@@ -621,8 +622,7 @@ static int _git_ssh_setup_conn(
done:
if (error < 0) {
- if (*stream)
- ssh_stream_free(*stream);
+ ssh_stream_free(*stream);
if (session)
libssh2_session_free(session);