[FFmpeg-cvslog] avformat/utils: Assert that stream_index is valid

Andreas Rheinhardt git at videolan.org
Thu Sep 26 02:53:47 EEST 2019


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Tue Sep 24 18:31:43 2019 +0200| [e045be92cdf5a2851900e8e85b815c29ae6f100a] | committer: James Almer

avformat/utils: Assert that stream_index is valid

There is currently an ordinary check for this (which would lead to a
memleak), but given that no demuxer should ever return a packet with an
invalid stream_index it is more appropriate for this to be an assert.

FATE passes with this change.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e045be92cdf5a2851900e8e85b815c29ae6f100a
---

 libavformat/utils.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3168931587..4d628119b6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -884,10 +884,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             continue;
         }
 
-        if (pkt->stream_index >= (unsigned)s->nb_streams) {
-            av_log(s, AV_LOG_ERROR, "Invalid stream index %d\n", pkt->stream_index);
-            continue;
-        }
+        av_assert0(pkt->stream_index < (unsigned)s->nb_streams &&
+                   "Invalid stream index.\n");
 
         st = s->streams[pkt->stream_index];
 



More information about the ffmpeg-cvslog mailing list