]> git.sesse.net Git - vlc/blobdiff - src/playlist/sort.c
Playlist: fix faulty duration sorting due to integer overflow
[vlc] / 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 )