summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-08 00:46:10 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-16 02:40:23 +0200
commit39195896f31aef7e96f1e4748e569d930df9d0c9 (patch)
tree8e14ceb4f5d88edca929c79d1603e852b4e86904 /libavformat/mux.c
parente0604d508e97322b88c8e4318516ead0cbc55170 (diff)
avformat/mux: Check pkt->stream_index before using it
This commit stops using pkt->stream_index as index in an AVFormatContext's streams array before actually comparing the value with the count of streams in said array. 96e5e6abb9851d7a26ba21703955d5826ac857c0 used pkt->stream_index in prepare_input_packet() before checking and 64063512227c4c87a7d16a1076481dc6baf19841 did likewise in write_packets_common(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 41659b19c9..f2de73af9b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -761,12 +761,13 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt)
static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
{
+ AVStream *st;
int ret;
- AVStream *st = s->streams[pkt->stream_index];
ret = check_packet(s, pkt);
if (ret < 0)
return ret;
+ st = s->streams[pkt->stream_index];
#if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX
/* sanitize the timestamps */
@@ -1176,10 +1177,11 @@ static int write_packets_from_bsfs(AVFormatContext *s, AVStream *st, AVPacket *p
static int write_packets_common(AVFormatContext *s, AVPacket *pkt, int interleaved)
{
- AVStream *st = s->streams[pkt->stream_index];
+ AVStream *st;
int ret = prepare_input_packet(s, pkt);
if (ret < 0)
return ret;
+ st = s->streams[pkt->stream_index];
ret = check_bitstream(s, st, pkt);
if (ret < 0)