[vlc-commits] ttml demux: Fix qsort usage

Hugo Beauzée-Luyssen git at videolan.org
Wed Sep 14 18:39:46 CEST 2016


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Sep 13 14:20:24 2016 +0200| [d291fd3ca5bffde37ee1850dda6f41979a588bd5] | committer: Hugo Beauzée-Luyssen

ttml demux: Fix qsort usage

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

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

diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index 93a3c0b..f5d07ba 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -367,7 +367,13 @@ static int addToArrayIfNotInside( vlc_array_t* p_array, mtime_t* p_elem )
 
 static int timeCmp( const void* p_time1, const void* p_time2 )
 {
-    return ( *(int*)p_time1 - *(int*)p_time2 );
+    mtime_t i_left = **(mtime_t* const*)p_time1;
+    mtime_t i_right = **(mtime_t* const*)p_time2;
+    if ( i_left == i_right )
+        return 0;
+    if ( i_left < i_right )
+        return -1;
+    return 1;
 }
 
 /*
@@ -500,7 +506,7 @@ static int ParseTimeOnSpan( demux_sys_t* p_sys, char* psz_text )
             goto error;
     }
 
-    qsort( p_times->pp_elems, p_times->i_count, sizeof( mtime_t ), timeCmp );
+    qsort( p_times->pp_elems, p_times->i_count, sizeof( mtime_t* ), timeCmp );
 
     subtitle_t* p_tmp_sub = realloc( p_sys->subtitle, sizeof( *p_sys->subtitle ) * ( p_times->i_count - 1 + p_sys->i_subtitles ) );
     if( unlikely( p_tmp_sub == NULL ) )



More information about the vlc-commits mailing list