Commit a17a624069 for ffmpeg
commit a17a6240695078537fb850fe713b4db1c87b09a3
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Wed Sep 30 00:10:42 2026 +0200
swresample: skip the rematrix stage when there are no samples
When resampling first, a call that produced no output passed midbuf to
swri_rematrix() before it was ever allocated, and copied channels did a
memcpy() of zero bytes from NULL. Skip rematrixing zero samples, as the
output conversion already does.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index cd84c731d9..52ad73836e 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -680,10 +680,10 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
if(postin != midbuf)
if ((out_count = resample(s, midbuf, out_count, postin, in_count)) < 0)
return out_count;
- if(midbuf != preout)
+ if(midbuf != preout && out_count)
swri_rematrix(s, preout, midbuf, out_count, preout==out);
}else{
- if(postin != midbuf)
+ if(postin != midbuf && in_count)
swri_rematrix(s, midbuf, postin, in_count, midbuf==out);
if(midbuf != preout)
if ((out_count = resample(s, preout, out_count, midbuf, in_count)) < 0)