ffmpeg.c: Fix the check for experimental codecs

Message ID 1310674635-33908-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö July 14, 2011, 8:17 p.m.
The variable 'codec' was used uninitialized here.
---
 ffmpeg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Ronald Bultje July 14, 2011, 8:31 p.m. | #1
Hi,

On Thu, Jul 14, 2011 at 1:17 PM, Martin Storsjö <martin@martin.st> wrote:
> The variable 'codec' was used uninitialized here.
> ---
>  ffmpeg.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

OK (auch).

Ronald
Martin Storsjö July 14, 2011, 8:38 p.m. | #2
On Thu, 14 Jul 2011, Ronald S. Bultje wrote:

> Hi,
> 
> On Thu, Jul 14, 2011 at 1:17 PM, Martin Storsjö <martin@martin.st> wrote:
> > The variable 'codec' was used uninitialized here.
> > ---
> >  ffmpeg.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> OK (auch).

Pushed - the second line of the fix wasn't actually necessary in practice, 
so I kept only the first line.

// Martin

Patch

diff --git a/ffmpeg.c b/ffmpeg.c
index dcc92ac..55aa853 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -516,20 +516,20 @@  static void assert_avoptions(AVDictionary *m)
 static void assert_codec_experimental(AVCodecContext *c, int encoder)
 {
     const char *codec_string = encoder ? "encoder" : "decoder";
     AVCodec *codec;
     if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
         c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
         av_log(NULL, AV_LOG_ERROR, "%s '%s' is experimental and might produce bad "
                 "results.\nAdd '-strict experimental' if you want to use it.\n",
                 codec_string, c->codec->name);
-        codec = encoder ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
-        if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
+        codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id);
+        if (codec && !(codec->capabilities & CODEC_CAP_EXPERIMENTAL))
             av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n",
                    codec_string, codec->name);
         ffmpeg_exit(1);
     }
 }
 
 /* similar to ff_dynarray_add() and av_fast_realloc() */
 static void *grow_array(void *array, int elem_size, int *size, int new_size)
 {