From: Carl Hetherington Date: Thu, 4 Jun 2020 22:07:29 +0000 (+0200) Subject: Fix crash when previewing projects with fewer than 6 audio channels; X-Git-Tag: v2.15.78~24 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=7904ba56bba3a107087546b09139b60544f5c272 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. --- 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 (