Skip to content

Commit

Permalink
sftp_init_reply_ok: fix small memory leak (libfuse#198)
Browse files Browse the repository at this point in the history
The leak was identified with ASAN: configure the project with
meson -Db_sanitize=address to reproduce.
  • Loading branch information
martinetd authored and Nikratio committed Nov 30, 2019
1 parent ab0e339 commit 8340a67
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand Down

0 comments on commit 8340a67

Please sign in to comment.