[FFmpeg-cvslog] avcodec/h263dec: Check against previous dimensions instead of coded
Michael Niedermayer
git at videolan.org
Thu Feb 27 19:09:11 EET 2025
ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Thu Jan 30 02:28:32 2025 +0100| [fb358672d9b510cd2852037114f58f7049b9f5f9] | committer: Michael Niedermayer
avcodec/h263dec: Check against previous dimensions instead of coded
Fixes: out of array access
Fixes: crash-a41ef3db699013f669b076f02f36942925f5a98c
Found-by: Kacper Michajlow <kasper93 at gmail.com>
Reviewed-by: Kacper Michajlow <kasper93 at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 0fe33c99a26a06a6875c4abfb96362a65145264b)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fb358672d9b510cd2852037114f58f7049b9f5f9
---
libavcodec/h263dec.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index c7a5379d3b..9b10fb382d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -426,7 +426,9 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
MpegEncContext *s = avctx->priv_data;
int ret;
int slice_ret = 0;
+
AVFrame *pict = data;
+ int bak_width, bak_height;
/* no supplementary picture */
if (buf_size == 0) {
@@ -490,6 +492,9 @@ retry:
// we need the idct permutation for reading a custom matrix
ff_mpv_idct_init(s);
+ bak_width = s->width;
+ bak_height = s->height;
+
/* let's go :-) */
if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
ret = ff_wmv2_decode_picture_header(s);
@@ -512,11 +517,12 @@ retry:
}
if (ret < 0 || ret == FRAME_SKIPPED) {
- if ( s->width != avctx->coded_width
- || s->height != avctx->coded_height) {
+ if ( s->width != bak_width
+ || s->height != bak_height) {
av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
- s->width = avctx->coded_width;
- s->height= avctx->coded_height;
+ s->width = bak_width;
+ s->height= bak_height;
+
}
}
if (ret == FRAME_SKIPPED)
More information about the ffmpeg-cvslog
mailing list