1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-23 11:47:45 +00:00

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.
This commit is contained in:
wm4 2018-10-14 15:11:33 +02:00 committed by Anton Kindestam
parent 8e3308d687
commit af9722cd3e

View File

@ -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,