From af9722cd3e9def4b09d50b6418e926567977b99b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 14 Oct 2018 15:11:33 +0200 Subject: demux: fix some theoretical UB with no impact If the number of chapters is 0, the chapter list can be NULL. clang complains that we pass NULL to qsort(). This is yet another pointless UB that exists for no reason other than wasting your time. --- demux/demux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 7d3a37663d..0bcb059c79 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -3027,8 +3027,10 @@ static int chapter_compare(const void *p1, const void *p2) static void demuxer_sort_chapters(demuxer_t *demuxer) { - qsort(demuxer->chapters, demuxer->num_chapters, - sizeof(struct demux_chapter), chapter_compare); + if (demuxer->num_chapters) { + qsort(demuxer->chapters, demuxer->num_chapters, + sizeof(struct demux_chapter), chapter_compare); + } } int demuxer_add_chapter(demuxer_t *demuxer, char *name, -- cgit v1.2.3