swresample/resample: free existing ResampleContext on reinit
authorJames Almer <jamrial@gmail.com>
Tue, 21 Mar 2017 15:03:44 +0000 (12:03 -0300)
committerJames Almer <jamrial@gmail.com>
Tue, 21 Mar 2017 15:03:44 +0000 (12:03 -0300)
Fixes memleak.

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
libswresample/resample.c

index 7b433d0..39c242b 100644 (file)
@@ -310,6 +310,7 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r
     if (!c || c->phase_count != phase_count || c->linear!=linear || c->factor != factor
            || c->filter_length != filter_length || c->format != format
            || c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
+        resample_free(&c);
         c = av_mallocz(sizeof(*c));
         if (!c)
             return NULL;