1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-05-31 16:21:13 +03:00

misc: Don't leak memory on ssh_path_expand_escape() on error.

This commit is contained in:
Andreas Schneider 2012-10-05 10:51:43 +02:00
parent dc8103925c
commit 61d032fc03

View File

@ -758,11 +758,13 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
default: default:
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
"Wrong escape sequence detected"); "Wrong escape sequence detected");
free(r);
return NULL; return NULL;
} }
if (x == NULL) { if (x == NULL) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
free(r);
return NULL; return NULL;
} }
@ -770,6 +772,8 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
if (i > MAX_BUF_SIZE) { if (i > MAX_BUF_SIZE) {
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
"String too long"); "String too long");
free(x);
free(r);
return NULL; return NULL;
} }
l = strlen(buf); l = strlen(buf);