From fc044a37afac6c5f52df8a911217fecfdaa6ec4b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 9 Mar 2021 12:47:38 +0100 Subject: [PATCH] resample: don't copy too much When we are in passthrough mode, copy only the min of input and output size or else we might overread/overwrite. See #875 --- spa/plugins/audioconvert/resample.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 33f4e6dfd..32e3f8f4e 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -844,9 +844,10 @@ static int impl_node_process(void *object) !SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE)); if (passthrough) { + uint32_t len = SPA_MIN(in_len, out_len); for (i = 0; i < sb->n_datas; i++) - memcpy(dst_datas[i], src_datas[i], in_len * sizeof(float)); - out_len = in_len; + memcpy(dst_datas[i], src_datas[i], len * sizeof(float)); + out_len = in_len = len; } else { resample_process(&this->resample, src_datas, &in_len, dst_datas, &out_len); }