diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-04 22:52:35 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-05 10:52:35 +0200 |
commit | 540a3b511e3c299a241965f4d94511c7b89de0ec (patch) | |
tree | 745ba228fae9848b38eca9db22b0895a04080158 /lib/io | |
parent | 9a20f40bb5e7106f3fa59affbbb81f30337ada6b (diff) |
libio: istream_get_line: fix memory leak in error path
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io')
-rw-r--r-- | lib/io/src/get_line.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/io/src/get_line.c b/lib/io/src/get_line.c index 1159037..e23383c 100644 --- a/lib/io/src/get_line.c +++ b/lib/io/src/get_line.c @@ -49,7 +49,7 @@ int istream_get_line(istream_t *strm, char **out, for (;;) { if (istream_precache(strm)) - return -1; + goto fail_free; if (strm->buffer_used == 0) { if (line_len == 0) @@ -111,6 +111,7 @@ int istream_get_line(istream_t *strm, char **out, fail_errno: fprintf(stderr, "%s: " PRI_SZ ": %s.\n", strm->get_filename(strm), *line_num, strerror(errno)); +fail_free: free(line); *out = NULL; return -1; |