From 7904ba56bba3a107087546b09139b60544f5c272 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Jun 2020 00:07:29 +0200 Subject: [PATCH] Fix crash when previewing projects with fewer than 6 audio channels; the old code tried to copy audio just because its channel had a non-0 value in the map without checking whether the destination channel actually existed. --- src/lib/util.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/util.cc b/src/lib/util.cc index e0efbc6f5..f9877523a 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -823,7 +823,9 @@ remap (shared_ptr input, int output_channels, AudioMapping m shared_ptr mapped (new AudioBuffers (output_channels, input->frames())); mapped->make_silent (); - for (int i = 0; i < map.input_channels(); ++i) { + int to_do = min (map.input_channels(), input->channels()); + + for (int i = 0; i < to_do; ++i) { for (int j = 0; j < mapped->channels(); ++j) { if (map.get (i, static_cast (j)) > 0) { mapped->accumulate_channel ( -- 2.30.2