[FFmpeg-cvslog] avformat/movenc: Check for reformatting errors when writing hint tracks
Andreas Rheinhardt
git at videolan.org
Sun Jan 26 17:52:44 EET 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Jan 23 17:08:31 2020 +0100| [e8518c2580f78a727d1e5d32c9cb6fe453ea5e53] | committer: James Almer
avformat/movenc: Check for reformatting errors when writing hint tracks
If this is not done, the avio_write() calls will cause segfaults
immediately afterwards on error.
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=e8518c2580f78a727d1e5d32c9cb6fe453ea5e53
---
libavformat/movenc.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5bf434c325..c0a5e1f2e0 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5461,8 +5461,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
/* from x264 or from bytestream H.264 */
/* NAL reformatting needed */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
- ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data,
- &size);
+ ret = ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data,
+ &size);
+ if (ret < 0)
+ return ret;
avio_write(pb, reformatted_data, size);
} else {
if (trk->cenc.aes_ctr) {
@@ -5479,14 +5481,19 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
/* extradata is Annex B, assume the bitstream is too and convert it */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
- ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL);
+ ret = ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data,
+ &size, 0, NULL);
+ if (ret < 0)
+ return ret;
avio_write(pb, reformatted_data, size);
} else {
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
}
} else if (par->codec_id == AV_CODEC_ID_AV1) {
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
- ff_av1_filter_obus_buf(pkt->data, &reformatted_data, &size);
+ ret = ff_av1_filter_obus_buf(pkt->data, &reformatted_data, &size);
+ if (ret < 0)
+ return ret;
avio_write(pb, reformatted_data, size);
} else {
size = ff_av1_filter_obus(pb, pkt->data, pkt->size);
More information about the ffmpeg-cvslog
mailing list