[vlc-commits] prefetch: fix wrong assert

Thomas Guillem git at videolan.org
Mon Nov 4 10:20:56 CET 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Oct 30 14:25:02 2019 +0100| [556d6fbde321ecfc27fa87d42438de3be6151f76] | committer: Thomas Guillem

prefetch: fix wrong assert

When the prefetch buffer is filled, when the buffer offset is 0 and when a seek
is done past the buffer length, history can be bigger than buffer_length.

This could lead to a read corruption but not a buffer overflow since the size
of the circular buffer is not impacted by this bug.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=556d6fbde321ecfc27fa87d42438de3be6151f76
---

 modules/stream_filter/prefetch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/stream_filter/prefetch.c b/modules/stream_filter/prefetch.c
index 087204ff99..2991c002bd 100644
--- a/modules/stream_filter/prefetch.c
+++ b/modules/stream_filter/prefetch.c
@@ -237,9 +237,8 @@ static void *Thread(void *data)
             }
 
             /* Discard some historical data to make room. */
-            len = history;
+            len = history > sys->buffer_length ? sys->buffer_length : history;
 
-            assert(len <= sys->buffer_length);
             sys->buffer_offset += len;
             sys->buffer_length -= len;
         }



More information about the vlc-commits mailing list