From 6afebbd0d9975c7aed9351a2a10740abeb111817 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 19 Jan 2014 20:13:51 +0100 Subject: demux_playlist: handle stream_read_line() errors As of this commit, stream_read_line() can't actually error (except in the case the passed in buffer is 0, which never happens here). This commit is preparation for the following commit, which checks harder whether the read data is actually text. Before this commit, an error was treated as end-of-file, but the data read so far was considered valid. --- demux/demux_playlist.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'demux/demux_playlist.c') diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 38011f80b7..b7a752468b 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -30,6 +30,7 @@ struct pl_parser { char buffer[8 * 1024]; int utf16; struct playlist *pl; + bool error; bool probing; }; @@ -40,6 +41,8 @@ static char *pl_get_line0(struct pl_parser *p) int len = strlen(res); if (len > 0 && res[len - 1] == '\n') res[len - 1] = '\0'; + } else { + p->error |= !p->s->eof; } return res; } @@ -58,7 +61,7 @@ static void pl_add(struct pl_parser *p, bstr entry) static bool pl_eof(struct pl_parser *p) { - return p->s->eof; + return p->error || p->s->eof; } static int parse_m3u(struct pl_parser *p) @@ -175,9 +178,10 @@ static int open_file(struct demuxer *demuxer, enum demux_check check) } p->probing = false; + p->error = false; p->s = demuxer->stream; p->utf16 = stream_skip_bom(p->s); - bool ok = fmt->parse(p) >= 0; + bool ok = fmt->parse(p) >= 0 && !p->error; if (ok) playlist_add_base_path(p->pl, mp_dirname(demuxer->filename)); demuxer->playlist = talloc_steal(demuxer, p->pl); -- cgit v1.2.3