From 2c3e03b4dc17f861f5148ea4f308e8c4a2e4d787 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
Date: Wed, 20 Mar 2019 06:27:33 +0200
Subject: [PATCH] avi: avoid undefined signed overflow

---
 modules/demux/avi/avi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 4d6869f52faf..2dfc7b4c6c8b 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1045,7 +1045,7 @@ static int Demux_Seekable( demux_t *p_demux )
 
         if( i_pos == -1 )
         {
-            int i_loop_count = 0;
+            unsigned short i_loop_count = 0;
 
             /* no valid index, we will parse directly the stream
              * in case we fail we will disable all finished stream */
@@ -1092,7 +1092,7 @@ static int Demux_Seekable( demux_t *p_demux )
                     {
                         vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
 
-                        if( !(i_loop_count % (1024 * 10)) )
+                        if( !i_loop_count )
                             msg_Warn( p_demux,
                                       "don't seem to find any data..." );
                     }
@@ -1786,7 +1786,7 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     avi_packet_t avi_pk;
-    int i_loop_count = 0;
+    unsigned short i_loop_count = 0;
 
     /* find first chunk of i_stream that isn't in index */
 
@@ -1827,7 +1827,7 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
             {
                 vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
 
-                if( !(i_loop_count % (1024 * 10)) )
+                if( !i_loop_count )
                     msg_Warn( p_demux, "don't seem to find any data..." );
             }
         }
@@ -2215,7 +2215,7 @@ static int AVI_PacketSearch( demux_t *p_demux )
 {
     demux_sys_t     *p_sys = p_demux->p_sys;
     avi_packet_t    avi_pk;
-    int             i_count = 0;
+    unsigned short  i_count = 0;
 
     for( ;; )
     {
@@ -2245,7 +2245,7 @@ static int AVI_PacketSearch( demux_t *p_demux )
         if( !(++i_count % 1024) )
         {
             vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
-            if( !(i_count % (1024 * 10)) )
+            if( !i_count )
                 msg_Warn( p_demux, "trying to resync..." );
         }
     }
-- 
GitLab