[FFmpeg-devel,5/5] avformat/mpeg: Don't use unintialized value

Submitted by Andreas Rheinhardt on Oct. 22, 2019, 1:16 p.m.

Details

Message ID 20191022131645.8394-5-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Oct. 22, 2019, 1:16 p.m.
vobsub_read_packet() didn't check whether an index in array of AVPackets
was valid and therefore used uninitialized values.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Actually I only wanted to use Valgrind to check for memleaks...

 libavformat/mpeg.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 73ade71d95..474afd06b9 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -930,6 +930,10 @@  static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
         FFDemuxSubtitlesQueue *tmpq = &vobsub->q[i];
         int64_t ts;
         av_assert0(tmpq->nb_subs);
+
+        if (tmpq->current_sub_idx >= tmpq->nb_subs)
+            continue;
+
         ts = tmpq->subs[tmpq->current_sub_idx].pts;
         if (ts < min_ts) {
             min_ts = ts;