diff --git a/vobsub.c b/vobsub.c index 9dfe49e41d..b6d06106f3 100644 --- a/vobsub.c +++ b/vobsub.c @@ -946,13 +946,11 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd) { ssize_t line_size; int res = -1; - do { size_t line_reserve = 0; char *line = NULL; + do { line_size = getline(&line, &line_reserve, fd); if (line_size < 0) { - if (line) - free(line); break; } if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#') @@ -984,6 +982,8 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd) mp_msg(MSGT_VOBSUB,MSGL_ERR, "ERROR in %s", line); break; } while (1); + if (line) + free(line); return res; }