[vlc-commits] demux: mp4: fix int overflow in track restart

Francois Cartegnie git at videolan.org
Mon Jan 16 17:09:47 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 16 16:52:48 2017 +0100| [3f9299d468fbe9aade97258fde56480f30e16e5a] | committer: Francois Cartegnie

demux: mp4: fix int overflow in track restart

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

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

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 8ded8c4..c4f3b9b 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -2928,7 +2928,8 @@ static void MP4_TrackRestart( demux_t *p_demux, mp4_track_t *p_track,
     uint32_t i_sample_pos_backup = p_track->i_sample;
     mp4_chunk_t *cchunk_backup = p_track->cchunk;
     p_track->cchunk = NULL;
-    mtime_t time_backup = p_track->i_time * p_track->i_timescale;
+    mtime_t time_backup = p_track->i_time;
+    uint32_t timescale_backup = p_track->i_timescale;
 
     /* Save previous format and ES */
     es_format_t fmtbackup;
@@ -2980,8 +2981,7 @@ static void MP4_TrackRestart( demux_t *p_demux, mp4_track_t *p_track,
     /* Restore fragmented pos */
     p_track->cchunk = cchunk_backup;
     p_track->i_sample = i_sample_pos_backup;
-    if( p_track->i_timescale )
-        p_track->i_time = time_backup / p_track->i_timescale;
+    p_track->i_time = time_backup * (uint64_t) p_track->i_timescale / timescale_backup;
 }
 
 /****************************************************************************



More information about the vlc-commits mailing list