1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-23 11:32:25 +03:00

misc: Fixed a possible memory leak.

This commit is contained in:
Andreas Schneider
2010-12-27 18:08:30 +01:00
parent 7c728acd12
commit a0e98f585a

View File

@@ -576,13 +576,14 @@ char *ssh_path_expand_tilde(const char *d) {
r = malloc(ld + lh + 1); r = malloc(ld + lh + 1);
if (r == NULL) { if (r == NULL) {
SAFE_FREE(h);
return NULL; return NULL;
} }
if (lh > 0) { if (lh > 0) {
memcpy(r, h, lh); memcpy(r, h, lh);
SAFE_FREE(h);
} }
SAFE_FREE(h);
memcpy(r + lh, p, ld + 1); memcpy(r + lh, p, ld + 1);
return r; return r;