summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-05 00:07:29 +0200
committerCarl Hetherington <cth@carlh.net>2020-06-05 00:07:29 +0200
commit7904ba56bba3a107087546b09139b60544f5c272 (patch)
tree6edf41e35940378653822f1b7283b7616a064f24 /src
parentebce2111f20e6b9cbd00ce8ec7e72c68cf176c29 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/util.cc4
1 files changed, 3 insertions, 1 deletions
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<const AudioBuffers> input, int output_channels, AudioMapping m
shared_ptr<AudioBuffers> 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<dcp::Channel> (j)) > 0) {
mapped->accumulate_channel (