diff options
author | wm4 <wm4@nowhere> | 2018-10-14 15:11:33 +0200 |
---|---|---|
committer | Anton Kindestam <antonki@kth.se> | 2018-12-06 10:33:52 +0100 |
commit | af9722cd3e9def4b09d50b6418e926567977b99b (patch) | |
tree | 312e24915b7d3951e1ce90104fea3858973dde1e /demux/demux.c | |
parent | 8e3308d687c3acdd0d572015b06efd5b492d93ee (diff) | |
download | mpv-af9722cd3e9def4b09d50b6418e926567977b99b.tar.bz2 mpv-af9722cd3e9def4b09d50b6418e926567977b99b.tar.xz |
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.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 6 |
1 files changed, 4 insertions, 2 deletions
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, |