From 3006ebf15c48a51801b90af2c2b7e0ccb7e8b051 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 14 Jun 2003 18:27:10 +0000 Subject: [PATCH] Fix a couple of memory leaks pointed out by Adam Bernstein. [originally from svn r3262] --- ssh.c | 5 ++++- sshdh.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ssh.c b/ssh.c index ce57b22d..16ceb013 100644 --- a/ssh.c +++ b/ssh.c @@ -2149,8 +2149,10 @@ static const char *connect_to_host(Ssh ssh, char *host, int port, */ logeventf(ssh, "Looking up host \"%s\"", host); addr = name_lookup(host, port, realhost, &ssh->cfg); - if ((err = sk_addr_error(addr)) != NULL) + if ((err = sk_addr_error(addr)) != NULL) { + sk_addr_free(addr); return err; + } /* * Open socket. @@ -2163,6 +2165,7 @@ static const char *connect_to_host(Ssh ssh, char *host, int port, ssh->fn = &fn_table; ssh->s = new_connection(addr, *realhost, port, 0, 1, nodelay, (Plug) ssh, &ssh->cfg); + sk_addr_free(addr); if ((err = sk_socket_error(ssh->s)) != NULL) { ssh->s = NULL; return err; diff --git a/sshdh.c b/sshdh.c index 27d5aab5..92351832 100644 --- a/sshdh.c +++ b/sshdh.c @@ -140,6 +140,8 @@ Bignum dh_create_e(void *handle, int nbits) } } while (bignum_cmp(ctx->x, One) <= 0 || bignum_cmp(ctx->x, ctx->q) >= 0); + sfree(buf); + /* * Done. Now compute e = g^x mod p. */