diff mbox

[FFmpeg-devel,1/2] opus_parser: fix leaking channel_maps on error

Message ID a0312196-61e0-60cd-e413-620070cbfd9f@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Dec. 8, 2016, 11:08 p.m. UTC
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/opus_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Dec. 9, 2016, 2:23 p.m. UTC | #1
On Fri, Dec 09, 2016 at 12:08:10AM +0100, Andreas Cadhalpun wrote:
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavcodec/opus_parser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/opus_parser.c b/libavcodec/opus_parser.c
> index c30fd7b..21a73ee 100644
> --- a/libavcodec/opus_parser.c
> +++ b/libavcodec/opus_parser.c
> @@ -116,11 +116,11 @@ static int opus_find_frame_end(AVCodecParserContext *ctx, AVCodecContext *avctx,
>  
>      if (avctx->extradata && !s->extradata_parsed) {
>          ret = ff_opus_parse_extradata(avctx, &s->ctx);
> +        av_freep(&s->ctx.channel_maps);
>          if (ret < 0) {
>              av_log(avctx, AV_LOG_ERROR, "Error parsing Ogg extradata.\n");
>              return AVERROR_INVALIDDATA;
>          }
> -        av_freep(&s->ctx.channel_maps);
>          s->extradata_parsed = 1;
>      }

isnt it more correct for ff_opus_parse_extradata() to cleanup what
it allocated on error ?

[...]
diff mbox

Patch

diff --git a/libavcodec/opus_parser.c b/libavcodec/opus_parser.c
index c30fd7b..21a73ee 100644
--- a/libavcodec/opus_parser.c
+++ b/libavcodec/opus_parser.c
@@ -116,11 +116,11 @@  static int opus_find_frame_end(AVCodecParserContext *ctx, AVCodecContext *avctx,
 
     if (avctx->extradata && !s->extradata_parsed) {
         ret = ff_opus_parse_extradata(avctx, &s->ctx);
+        av_freep(&s->ctx.channel_maps);
         if (ret < 0) {
             av_log(avctx, AV_LOG_ERROR, "Error parsing Ogg extradata.\n");
             return AVERROR_INVALIDDATA;
         }
-        av_freep(&s->ctx.channel_maps);
         s->extradata_parsed = 1;
     }