From da3b2d68a3ec750186448eadf6e92a118dcd6ef1 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 27 Dec 2010 18:08:30 +0100 Subject: [PATCH] misc: Fixed a possible memory leak. (cherry picked from commit a0e98f585a36e0032545107dbd90c6adab40e09b) --- libssh/misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libssh/misc.c b/libssh/misc.c index e544cb2f..7e842770 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -548,13 +548,14 @@ char *ssh_path_expand_tilde(const char *d) { r = malloc(ld + lh + 1); if (r == NULL) { + SAFE_FREE(h); return NULL; } if (lh > 0) { memcpy(r, h, lh); - SAFE_FREE(h); } + SAFE_FREE(h); memcpy(r + lh, p, ld + 1); return r;