Skip to content

Commit 8340a67

Browse files
martinetdNikratio
authored andcommitted
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.
1 parent ab0e339 commit 8340a67

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sshfs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,14 @@ static int sftp_init_reply_ok(struct conn *conn, struct buffer *buf,
15961596
}
15971597

15981598
do {
1599-
char *ext;
1600-
char *extdata;
1599+
char *ext = NULL;
1600+
char *extdata = NULL;
16011601

16021602
if (buf_get_string(&buf2, &ext) == -1 ||
16031603
buf_get_string(&buf2, &extdata) == -1) {
16041604
buf_free(&buf2);
1605+
free(ext);
1606+
free(extdata);
16051607
return -1;
16061608
}
16071609

@@ -1621,6 +1623,9 @@ static int sftp_init_reply_ok(struct conn *conn, struct buffer *buf,
16211623
if (strcmp(ext, SFTP_EXT_FSYNC) == 0 &&
16221624
strcmp(extdata, "1") == 0)
16231625
sshfs.ext_fsync = 1;
1626+
1627+
free(ext);
1628+
free(extdata);
16241629
} while (buf2.len < buf2.size);
16251630
buf_free(&buf2);
16261631
}

0 commit comments

Comments
 (0)