diff mbox series

[FFmpeg-devel,2/3] avcodec/mjpegdec: Check initializing Huffman tables

Message ID HE1PR0301MB2154546821E82DF39D5053D58F799@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit d5ddfec6c3ce0ff743e3d67c42a1a59d3afe8e8c
Headers show
Series [FFmpeg-devel,1/3] avcodec/mjpegdec: Fix leak in case of invalid external Huffman tables
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 April 3, 2021, 2:22 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Is it actually intended that the decoder tries to use external Huffman
tables purely based on the value of the option, even when there is no
extradata at all (in which case init_get_bits() fails)?

 libavcodec/mjpegdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer April 3, 2021, 3:41 p.m. UTC | #1
On Sat, Apr 03, 2021 at 04:22:26PM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Is it actually intended that the decoder tries to use external Huffman
> tables purely based on the value of the option, even when there is no
> extradata at all (in which case init_get_bits() fails)?
> 
>  libavcodec/mjpegdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index 776797d35b..d0c933b52e 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -154,7 +154,8 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
>          if (ff_mjpeg_decode_dht(s)) {
>              av_log(avctx, AV_LOG_ERROR,
>                     "error using external huffman table, switching back to internal\n");
> -            init_default_huffman_tables(s);
> +            if ((ret = init_default_huffman_tables(s)) < 0)
> +                return ret;
>          }
>      }
>      if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */

probably ok

[...]
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 776797d35b..d0c933b52e 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -154,7 +154,8 @@  av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
         if (ff_mjpeg_decode_dht(s)) {
             av_log(avctx, AV_LOG_ERROR,
                    "error using external huffman table, switching back to internal\n");
-            init_default_huffman_tables(s);
+            if ((ret = init_default_huffman_tables(s)) < 0)
+                return ret;
         }
     }
     if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */