[FFmpeg-devel] [PATCH 4/6] avcodec/rv10: Don't presume context to be initialized

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Apr 5 04:44:32 EEST 2021


In case of resolution changes rv20_decode_picture_header() closes and
reopens its MpegEncContext; it checks the latter for errors, yet when
an error happens, it might happen that no new attempt at
reinitialization is performed when decoding the next frame; this leads
to crashes lateron.

This commit changes this by making sure that initialization will always
be attempted if the context is currently not initialized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/rv10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 89b838ad15..bd70689cab 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -226,7 +226,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
             new_w = rv->orig_width;
             new_h = rv->orig_height;
         }
-        if (new_w != s->width || new_h != s->height) {
+        if (new_w != s->width || new_h != s->height || !s->context_initialized) {
             AVRational old_aspect = s->avctx->sample_aspect_ratio;
             av_log(s->avctx, AV_LOG_DEBUG,
                    "attempting to change resolution to %dx%d\n", new_w, new_h);
-- 
2.27.0



More information about the ffmpeg-devel mailing list