diff mbox series

[FFmpeg-devel,40/40] avcodec/ffwavesynth: Cleanup generically after init failure

Message ID 20200914052747.124118-24-andreas.rheinhardt@gmail.com
State Accepted
Commit 01506c290adb6d033e0167b95e52d37bc5ceedeb
Headers show
Series [FFmpeg-devel,01/16] avcodec/snowdec: Use ff_snow_common_init() directly | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 14, 2020, 5:27 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/ffwavesynth.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Andreas Rheinhardt Sept. 17, 2020, 3:58 a.m. UTC | #1
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/ffwavesynth.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c
> index d92bb38c45..c99bac90ea 100644
> --- a/libavcodec/ffwavesynth.c
> +++ b/libavcodec/ffwavesynth.c
> @@ -323,13 +323,11 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
>      r = wavesynth_parse_extradata(avc);
>      if (r < 0) {
>          av_log(avc, AV_LOG_ERROR, "Invalid intervals definitions.\n");
> -        goto fail;
> +        return r;
>      }
>      ws->sin = av_malloc(sizeof(*ws->sin) << SIN_BITS);
> -    if (!ws->sin) {
> -        r = AVERROR(ENOMEM);
> -        goto fail;
> -    }
> +    if (!ws->sin)
> +        return AVERROR(ENOMEM);
>      for (i = 0; i < 1 << SIN_BITS; i++)
>          ws->sin[i] = floor(32767 * sin(2 * M_PI * i / (1 << SIN_BITS)));
>      ws->dither_state = MKTAG('D','I','T','H');
> @@ -340,11 +338,6 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
>      wavesynth_seek(ws, 0);
>      avc->sample_fmt = AV_SAMPLE_FMT_S16;
>      return 0;
> -
> -fail:
> -    av_freep(&ws->inter);
> -    av_freep(&ws->sin);
> -    return r;
>  }
>  
>  static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts,
> @@ -476,4 +469,5 @@ AVCodec ff_ffwavesynth_decoder = {
>      .close          = wavesynth_close,
>      .decode         = wavesynth_decode,
>      .capabilities   = AV_CODEC_CAP_DR1,
> +    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> 
Will apply the rest of this patchset tomorrow if there are no objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c
index d92bb38c45..c99bac90ea 100644
--- a/libavcodec/ffwavesynth.c
+++ b/libavcodec/ffwavesynth.c
@@ -323,13 +323,11 @@  static av_cold int wavesynth_init(AVCodecContext *avc)
     r = wavesynth_parse_extradata(avc);
     if (r < 0) {
         av_log(avc, AV_LOG_ERROR, "Invalid intervals definitions.\n");
-        goto fail;
+        return r;
     }
     ws->sin = av_malloc(sizeof(*ws->sin) << SIN_BITS);
-    if (!ws->sin) {
-        r = AVERROR(ENOMEM);
-        goto fail;
-    }
+    if (!ws->sin)
+        return AVERROR(ENOMEM);
     for (i = 0; i < 1 << SIN_BITS; i++)
         ws->sin[i] = floor(32767 * sin(2 * M_PI * i / (1 << SIN_BITS)));
     ws->dither_state = MKTAG('D','I','T','H');
@@ -340,11 +338,6 @@  static av_cold int wavesynth_init(AVCodecContext *avc)
     wavesynth_seek(ws, 0);
     avc->sample_fmt = AV_SAMPLE_FMT_S16;
     return 0;
-
-fail:
-    av_freep(&ws->inter);
-    av_freep(&ws->sin);
-    return r;
 }
 
 static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts,
@@ -476,4 +469,5 @@  AVCodec ff_ffwavesynth_decoder = {
     .close          = wavesynth_close,
     .decode         = wavesynth_decode,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };