From a51c09fc68c5adb8ce7c0855e9a35a191e3515fa Mon Sep 17 00:00:00 2001 From: James Stembridge Date: Thu, 19 Aug 2004 19:59:14 +0000 Subject: Don't read past end of index when seeking to end of file CVS patchset: 6901 CVS date: 2004/08/19 19:59:14 --- src/demuxers/demux_real.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 23298ec32..789d623b4 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -31,7 +31,7 @@ * * Based on FFmpeg's libav/rm.c. * - * $Id: demux_real.c,v 1.102 2004/08/17 19:49:51 jstembridge Exp $ + * $Id: demux_real.c,v 1.103 2004/08/19 19:59:14 jstembridge Exp $ */ #ifdef HAVE_CONFIG_H @@ -1442,11 +1442,12 @@ static int demux_real_seek (demux_plugin_t *this_gen, other_index = this->video_stream->index; } + /* FIXME: binary search would be quicker */ if(start_pos) { - while((index[i+1].offset < start_pos) && (i < entries - 1)) + while((i < entries - 1) && (index[i+1].offset < start_pos)) i++; } else if(start_time) { - while((index[i+1].timestamp < start_time) && (i < entries - 1)) + while((i < entries - 1) && (index[i+1].timestamp < start_time)) i++; } -- cgit v1.2.3