From f87f4ab8367fd6c72c210df5d51b09e72790c616 Mon Sep 17 00:00:00 2001 From: Alexander Lamaison Date: Sun, 7 Mar 2010 16:18:46 +0000 Subject: [PATCH] Fix memory leak in libssh2_knownhost_add. --- src/knownhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/knownhost.c b/src/knownhost.c index 65f0060..985ef34 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -158,9 +158,11 @@ libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts, "entry"); /* make sure we have a key type set */ - if(!(typemask & LIBSSH2_KNOWNHOST_KEY_MASK)) - return libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL, - "No key type set"); + if(!(typemask & LIBSSH2_KNOWNHOST_KEY_MASK)) { + rc = libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL, + "No key type set"); + goto error; + } memset(entry, 0, sizeof(struct known_host));