[vlc-devel] [PATCH] prefetch: fix wrong assert

Thomas Guillem thomas at gllm.fr
Thu Oct 31 09:03:10 CET 2019


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.
---
 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 087204ff991..22d37f6464e 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 = __MIN(history, sys->buffer_length);
 
-            assert(len <= sys->buffer_length);
             sys->buffer_offset += len;
             sys->buffer_length -= len;
         }
-- 
2.20.1



More information about the vlc-devel mailing list