]> git.sesse.net Git - vlc/commitdiff
Playlist: fix faulty duration sorting due to integer overflow
authorJakob Leben <jleben@videolan.org>
Tue, 2 Mar 2010 10:12:03 +0000 (11:12 +0100)
committerJakob Leben <jleben@videolan.org>
Tue, 2 Mar 2010 10:14:18 +0000 (11:14 +0100)
close #3361

src/playlist/sort.c

index 95abbbea364dc202688805fd980a93684b499f2b..d6e5c3faea19144945a3c3c0b9a7a2f0058e97cc 100644 (file)
@@ -240,8 +240,11 @@ SORTFN( SORT_DESCRIPTION, first, second )
 
 SORTFN( SORT_DURATION, first, second )
 {
-    return input_item_GetDuration( first->p_input ) -
-           input_item_GetDuration( second->p_input );
+    mtime_t time1 = input_item_GetDuration( first->p_input );
+    mtime_t time2 = input_item_GetDuration( second->p_input );
+    int i_ret = time1 > time2 ? 1 :
+                    ( time1 == time2 ? 0 : -1 );
+    return i_ret;
 }
 
 SORTFN( SORT_GENRE, first, second )