[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant

Andreas Rheinhardt git at videolan.org
Thu Apr 8 13:53:50 EEST 2021


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Apr  6 15:45:42 2021 +0200| [5c457c673fbd8d2d0ef1ed10dbd269ee3570e628] | committer: Andreas Rheinhardt

avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant

The (deprecated) field AVCodecContext.mpeg_quant has no range
restriction; MpegEncContext.mpeg_quant is restricted to 0..1.
If the former is set, the latter is overwritten with it without
checking the range. This can trigger an av_assert2() with the MPEG-4
encoder when writing said field.

Fix this by just setting MpegEncContext.mpeg_quant to 1 if
AVCodecContext.mpeg_quant is set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit d393c45051ddaf6146e7e29ec2ea97035a727529)

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

 libavcodec/mpegvideo_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 29572dd61e..eb13d57d2b 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -627,7 +627,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #if FF_API_PRIVATE_OPT
     FF_DISABLE_DEPRECATION_WARNINGS
     if (avctx->mpeg_quant)
-        s->mpeg_quant = avctx->mpeg_quant;
+        s->mpeg_quant = 1;
     FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 



More information about the ffmpeg-cvslog mailing list