diff mbox series

[FFmpeg-devel,1/4] avcodec/vp3: Don't try to decode VP4 when VP4 decoder is disabled

Message ID HE1PR0301MB2154F5D9E576C018E923F25A8F569@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 9afb291267db04568da0fac2ce391380c48d7047
Headers show
Series [FFmpeg-devel,1/4] avcodec/vp3: Don't try to decode VP4 when VP4 decoder is disabled
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 8, 2021, 1:25 a.m. UTC
Otherwise decoding will crash lateron; e.g. because dct_tokens
is never set or because a VLC that has not been allocated is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp3.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Peter Ross May 9, 2021, 1:42 a.m. UTC | #1
On Sat, May 08, 2021 at 03:25:06AM +0200, Andreas Rheinhardt wrote:
> Otherwise decoding will crash lateron; e.g. because dct_tokens
> is never set or because a VLC that has not been allocated is used.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/vp3.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 0cae075452..9aa84e83b7 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -2335,9 +2335,13 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
>      if (ret < 0)
>          return ret;
>  
> -    if (avctx->codec_tag == MKTAG('V', 'P', '4', '0'))
> +    if (avctx->codec_tag == MKTAG('V', 'P', '4', '0')) {
>          s->version = 3;
> -    else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
> +#if !CONFIG_VP4_DECODER
> +        av_log(avctx, AV_LOG_ERROR, "This build does not support decoding VP4.\n");
> +        return AVERROR_DECODER_NOT_FOUND;
> +#endif
> +    } else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
>          s->version = 0;
>      else
>          s->version = 1;
> -- 
> 2.27.0

This patchset 1-4 all looks good to me.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
diff mbox series

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 0cae075452..9aa84e83b7 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2335,9 +2335,13 @@  static av_cold int vp3_decode_init(AVCodecContext *avctx)
     if (ret < 0)
         return ret;
 
-    if (avctx->codec_tag == MKTAG('V', 'P', '4', '0'))
+    if (avctx->codec_tag == MKTAG('V', 'P', '4', '0')) {
         s->version = 3;
-    else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
+#if !CONFIG_VP4_DECODER
+        av_log(avctx, AV_LOG_ERROR, "This build does not support decoding VP4.\n");
+        return AVERROR_DECODER_NOT_FOUND;
+#endif
+    } else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0'))
         s->version = 0;
     else
         s->version = 1;