diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-03 22:05:21 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-10-03 20:50:49 +0200 |
commit | 805ec95f8eb5664bf11c4c9190c868fd5521d80a (patch) | |
tree | 00d45326383966cf6589c73c650ea4f8fc76ae36 /libavformat/mux.c | |
parent | f80120756879293b66b5ff3d74b2d3fcb052693a (diff) | |
download | ffmpeg-805ec95f8eb5664bf11c4c9190c868fd5521d80a.tar.gz |
avformat/mux: Sanitize packets without data and side-data
The BSF API treats such packets as signalling EOF and therefore
such a packet might corrupt the BSF state. In such a case,
the guarantee that av_interleaved_write_frame() always frees
the packet is not upheld.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index 2053a5636e..d7b2bdb4b3 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -787,6 +787,13 @@ static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt) if (sti->is_intra_only) pkt->flags |= AV_PKT_FLAG_KEY; + if (!pkt->data && !pkt->side_data_elems) { + /* Such empty packets signal EOS for the BSF API; so sanitize + * the packet by allocating data of size 0 (+ padding). */ + av_buffer_unref(&pkt->buf); + return av_packet_make_refcounted(pkt); + } + return 0; } |