diff mbox series

[FFmpeg-devel,4/7] avformat/mm: Check for existence of audio stream

Message ID 20200709103542.19909-4-andreas.rheinhardt@gmail.com
State Accepted
Commit ec59dc73f0cc8930bf5dae389cd76d049d537ca7
Headers show
Series [FFmpeg-devel,1/7] avformat/avc: Fix undefined shift and assert when reading exp-golomb num
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 9, 2020, 10:35 a.m. UTC
No audio stream is created unconditionally and if none has been created,
no packet with stream_index 1 may be returned. This fixes an assert in
ff_read_packet() in libavformat/utils reported in ticket #8782.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michael Niedermayer July 10, 2020, 6:12 p.m. UTC | #1
On Thu, Jul 09, 2020 at 12:35:39PM +0200, Andreas Rheinhardt wrote:
> No audio stream is created unconditionally and if none has been created,
> no packet with stream_index 1 may be returned. This fixes an assert in
> ff_read_packet() in libavformat/utils reported in ticket #8782.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/mm.c | 2 ++
>  1 file changed, 2 insertions(+)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mm.c b/libavformat/mm.c
index d40fd12acc..02ffbcd824 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -175,6 +175,8 @@  static int read_packet(AVFormatContext *s,
             return 0;
 
         case MM_TYPE_AUDIO :
+            if (s->nb_streams < 2)
+                return AVERROR_INVALIDDATA;
             if ((ret = av_get_packet(s->pb, pkt, length)) < 0)
                 return ret;
             pkt->stream_index = 1;