[FFmpeg-devel] [PATCH 2/4] avfilter/asrc_sinc: fix leak in config_input()
Lidong Yan
yldhome2d2 at gmail.com
Tue Jun 17 17:14:14 EEST 2025
In config_input(), fir_to_phase() allocates memory in h[longer].
But if av_calloc() to s->coeffs failed, memory in h[longer] would
leak. Add av_free(h[longer]) in !s->coeffs path.
Signed-off-by: Lidong Yan <502024330056 at smail.nju.edu.cn>
---
libavfilter/asrc_sinc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
index 6ff3303316..198c322665 100644
--- a/libavfilter/asrc_sinc.c
+++ b/libavfilter/asrc_sinc.c
@@ -370,8 +370,10 @@ static int config_output(AVFilterLink *outlink)
s->n = 1 << (av_log2(n) + 1);
s->rdft_len = 1 << av_log2(n);
s->coeffs = av_calloc(s->n, sizeof(*s->coeffs));
- if (!s->coeffs)
+ if (!s->coeffs) {
+ av_free(h[longer]);
return AVERROR(ENOMEM);
+ }
for (i = 0; i < n; i++)
s->coeffs[i] = h[longer][i];
--
2.50.0-rc1
More information about the ffmpeg-devel
mailing list