summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-10-14 15:11:33 +0200
committerAnton Kindestam <antonki@kth.se>2018-12-06 10:33:52 +0100
commitaf9722cd3e9def4b09d50b6418e926567977b99b (patch)
tree312e24915b7d3951e1ce90104fea3858973dde1e
parent8e3308d687c3acdd0d572015b06efd5b492d93ee (diff)
downloadmpv-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.
-rw-r--r--demux/demux.c6
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,