summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-19 20:13:51 +0100
committerwm4 <wm4@nowhere>2014-01-19 21:15:54 +0100
commit6afebbd0d9975c7aed9351a2a10740abeb111817 (patch)
treefa6e1535189d9f45c51b0437fcb20b45c0954aee /demux
parenta0cc204528b80b0649fa805b5c2efe97977b53fa (diff)
downloadmpv-6afebbd0d9975c7aed9351a2a10740abeb111817.tar.bz2
mpv-6afebbd0d9975c7aed9351a2a10740abeb111817.tar.xz
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.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_playlist.c8
1 files changed, 6 insertions, 2 deletions
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);