From ce2b3853188240e46f77165217a49a6ac87ee0f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 11 Aug 2021 14:53:17 +0200 Subject: [PATCH] filter-chain: protect against bad values --- src/modules/module-filter-chain/builtin_plugin.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/module-filter-chain/builtin_plugin.c b/src/modules/module-filter-chain/builtin_plugin.c index d563e7ab2..e26d2be09 100644 --- a/src/modules/module-filter-chain/builtin_plugin.c +++ b/src/modules/module-filter-chain/builtin_plugin.c @@ -457,11 +457,16 @@ static void * convolver_instantiate(const struct fc_descriptor * Descriptor, impl->rate = SampleRate; - if (length == 0) + if (delay < 0) + delay = 0; + + if (length <= 0) length = info.frames; else length = SPA_MIN(length, info.frames); + if (offset < 0) + offset = 0; length -= SPA_MIN(offset, length); n_frames = delay + length; @@ -473,7 +478,8 @@ static void * convolver_instantiate(const struct fc_descriptor * Descriptor, if (samples == NULL) return NULL; - sf_seek(f, offset, SEEK_SET); + if (offset > 0) + sf_seek(f, offset, SEEK_SET); sf_readf_float(f, samples + (delay * info.channels), length); channel = channel % info.channels;