diff mbox

[FFmpeg-devel] avformat/ac3enc: Fix memleak

Message ID 20191017091154.23947-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 097c917c147661f5378dae8fe3f7e46f43236426
Headers show

Commit Message

Andreas Rheinhardt Oct. 17, 2019, 9:11 a.m. UTC
Fixes ticket #8294.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/ac3enc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

James Almer Oct. 17, 2019, 1:31 p.m. UTC | #1
On 10/17/2019 6:11 AM, Andreas Rheinhardt wrote:
> Fixes ticket #8294.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/ac3enc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
> index 76872a8fe0..25318f8631 100644
> --- a/libavcodec/ac3enc.c
> +++ b/libavcodec/ac3enc.c
> @@ -2051,7 +2051,8 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
>          av_freep(&block->cpl_coord_mant);
>      }
>  
> -    s->mdct_end(s);
> +    if (s->mdct_end)
> +        s->mdct_end(s);
>  
>      return 0;
>  }
> @@ -2433,7 +2434,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
>  
>      ret = validate_options(s);
>      if (ret)
> -        return ret;
> +        goto init_fail;
>  
>      avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks;
>      avctx->initial_padding = AC3_BLOCK_SIZE;

LGTM. I had missed this patch when i reviewed Paul's. It's simpler than
his and it was sent first, so probably better to apply this one.
diff mbox

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 76872a8fe0..25318f8631 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2051,7 +2051,8 @@  av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
         av_freep(&block->cpl_coord_mant);
     }
 
-    s->mdct_end(s);
+    if (s->mdct_end)
+        s->mdct_end(s);
 
     return 0;
 }
@@ -2433,7 +2434,7 @@  av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
 
     ret = validate_options(s);
     if (ret)
-        return ret;
+        goto init_fail;
 
     avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks;
     avctx->initial_padding = AC3_BLOCK_SIZE;