sftp_init_reply_ok: fix small memory leak (#198)

The leak was identified with ASAN: configure the project with
meson -Db_sanitize=address to reproduce.
This commit is contained in:
Dominique Martinet 2019-11-30 12:42:40 +01:00 committed by Nikolaus Rath
parent ab0e339e80
commit 8340a67b31
1 changed files with 7 additions and 2 deletions

View File

@ -1596,12 +1596,14 @@ static int sftp_init_reply_ok(struct conn *conn, struct buffer *buf,
}
do {
char *ext;
char *extdata;
char *ext = NULL;
char *extdata = NULL;
if (buf_get_string(&buf2, &ext) == -1 ||
buf_get_string(&buf2, &extdata) == -1) {
buf_free(&buf2);
free(ext);
free(extdata);
return -1;
}
@ -1621,6 +1623,9 @@ static int sftp_init_reply_ok(struct conn *conn, struct buffer *buf,
if (strcmp(ext, SFTP_EXT_FSYNC) == 0 &&
strcmp(extdata, "1") == 0)
sshfs.ext_fsync = 1;
free(ext);
free(extdata);
} while (buf2.len < buf2.size);
buf_free(&buf2);
}