Fixes memleak (See opus-testvector12 fate test).
Signed-off-by: James Almer <[email protected]>
---
libswresample/resample.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libswresample/resample.c b/libswresample/resample.c
index 144b232462..ad6410142b 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -276,6 +276,13 @@ fail:
return ret;
}
+static void resample_free(ResampleContext **c){
+ if(!*c)
+ return;
+ av_freep(&(*c)->filter_bank);
+ av_freep(c);
+}
+
static ResampleContext *resample_init(ResampleContext *c, int out_rate, int
in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat
format, enum SwrFilterType filter_type, double kaiser_beta,
double precision, int cheby, int
exact_rational)
@@ -302,6 +309,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;
@@ -371,13 +379,6 @@ error:
return NULL;
}
-static void resample_free(ResampleContext **c){
- if(!*c)
- return;
- av_freep(&(*c)->filter_bank);
- av_freep(c);
-}
-
static int rebuild_filter_bank_with_compensation(ResampleContext *c)
{
uint8_t *new_filter_bank;
--
2.12.0
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel