]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/rv10: Don't presume context to be initialized
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sun, 4 Apr 2021 19:30:33 +0000 (21:30 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Wed, 7 Apr 2021 23:16:25 +0000 (01:16 +0200)
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 fixes this by making sure that initialization will always
be attempted if the context is currently not initialized.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/rv10.c

index 89b838ad1559661f6d944611a05fffc75fd0fa00..bd70689caba07be2135263e481dc6f785ca36a8a 100644 (file)
@@ -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);