[vlc-commits] demux: flac: align to avoid overflow on seek (fix #10000)

Francois Cartegnie git at videolan.org
Mon Dec 9 20:06:22 CET 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec  9 19:55:18 2013 +0100| [de16d374e45d1497883fdc3c5804e6bd3f877d12] | committer: Francois Cartegnie

demux: flac: align to avoid overflow on seek (fix #10000)

Align seek time on second to avoid overflow on seek.

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

 modules/demux/flac.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 1356835..02e6d4f 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -312,6 +312,7 @@ static int ControlSetTime( demux_t *p_demux, int64_t i_time )
         int64_t i_delta_offset;
         int64_t i_next_time;
         int64_t i_next_offset;
+        uint32_t i_time_align = 1;
 
         if( i+1 < p_sys->i_seekpoint )
         {
@@ -325,14 +326,19 @@ static int ControlSetTime( demux_t *p_demux, int64_t i_time )
         }
 
         i_delta_offset = 0;
+
+        if ( INT64_MAX / i_delta_time < (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) )
+            i_time_align = 1000000;
+
         if( i_next_time-p_sys->seekpoint[i]->i_time_offset > 0 )
-            i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * i_delta_time /
-                             (i_next_time-p_sys->seekpoint[i]->i_time_offset);
+            i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * (i_delta_time / i_time_align) /
+                             ((i_next_time-p_sys->seekpoint[i]->i_time_offset) / i_time_align);
 
         if( stream_Seek( p_demux->s, p_sys->seekpoint[i]->i_byte_offset+p_sys->i_data_pos + i_delta_offset ) )
             return VLC_EGENERIC;
 
         p_sys->i_pts_start = p_sys->i_pts;
+        i_delta_time = ( i_delta_time / i_time_align ) * i_time_align;
         p_sys->i_time_offset = (p_sys->seekpoint[i]->i_time_offset+i_delta_time) - p_sys->i_pts;
     }
     return VLC_SUCCESS;



More information about the vlc-commits mailing list