misc: Fixed a possible memory leak.

(cherry picked from commit a0e98f585a)
This commit is contained in:
Andreas Schneider
2010-12-27 18:08:30 +01:00
parent 4638b353d5
commit da3b2d68a3

View File

@@ -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;