avformat/subtitles: Check nb_subs in ff_subtitles_queue_finalize()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 4 Oct 2019 15:10:38 +0000 (17:10 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 6 Oct 2019 18:00:59 +0000 (20:00 +0200)
Fixes: null pointer dereference
Fixes: 17828/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5645915116797952
Fixes: Ticket8147

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/subtitles.c

index 659c99d..a3240d8 100644 (file)
@@ -194,6 +194,9 @@ void ff_subtitles_queue_finalize(void *log_ctx, FFDemuxSubtitlesQueue *q)
 {
     int i;
 
+    if (!q->nb_subs)
+        return;
+
     qsort(q->subs, q->nb_subs, sizeof(*q->subs),
           q->sort == SUB_SORT_TS_POS ? cmp_pkt_sub_ts_pos
                                      : cmp_pkt_sub_pos_ts);