From 475c79b11056e35dd0716408cd2f1499577b9421 Mon Sep 17 00:00:00 2001 From: Thomas Viehmann Date: Wed, 31 Dec 2008 22:47:32 +0100 Subject: check for negative return values of read when demuxing mng streams Some input plugins (e.g. file) return negative error codes from read, this should be treated as no (more) data available. This is particularly bad because the error code is assigned to an unsigned integer variable for use by the caller. Based on a patch by Matthias Hopf --- src/demuxers/demux_mng.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c index b57a349c5..d0d83ff80 100644 --- a/src/demuxers/demux_mng.c +++ b/src/demuxers/demux_mng.c @@ -104,7 +104,12 @@ static mng_bool mymng_close_stream(mng_handle mngh){ static mng_bool mymng_read_stream(mng_handle mngh, mng_ptr buffer, mng_uint32 size, mng_uint32 *bytesread){ demux_mng_t *this = (demux_mng_t*)mng_get_userdata(mngh); - *bytesread = this->input->read(this->input, buffer, size); + off_t n = this->input->read(this->input, buffer, size); + if (n < 0) { + *bytesread = 0; + return MNG_FALSE; + } + *bytesread = n; return MNG_TRUE; } -- cgit v1.2.3