[vlc-commits] subtitle: handle INT_MAX in qsort
Ilkka Ollakka
git at videolan.org
Sun Oct 4 20:12:12 CEST 2015
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Oct 4 21:01:02 2015 +0300| [17135fda27d87ea7e7e397ae9baac2f735fed150] | committer: Ilkka Ollakka
subtitle: handle INT_MAX in qsort
Return only -1,0,1 and not directly subtraction, as like Remi pointed
out, result can exceed INT_MAX.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=17135fda27d87ea7e7e397ae9baac2f735fed150
---
modules/demux/subtitle.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 0afb9d1..a99d146 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -761,7 +761,10 @@ static int Demux( demux_t *p_demux )
static int subtitle_cmp( const void *first, const void *second )
{
- return ((subtitle_t *)(first))->i_start - ((subtitle_t *)(second))->i_start;
+ int64_t result = ((subtitle_t *)(first))->i_start - ((subtitle_t *)(second))->i_start;
+ /* Return -1, 0 ,1, and not directly substraction
+ * as result can be > INT_MAX */
+ return result == 0 ? 0 : result > 0 ? 1 : -1;
}
/*****************************************************************************
* Fix: fix time stamp and order of subtitle
More information about the vlc-commits
mailing list