Fix crash in audio mapping view in various circumstances.
authorCarl Hetherington <cth@carlh.net>
Sat, 4 May 2019 21:43:45 +0000 (21:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 4 May 2019 21:43:45 +0000 (21:43 +0000)
src/wx/audio_mapping_view.cc

index 27094d3b2b9eca099c939459089d87cd5e1d829a..ef37e1b7a32d88b194de4c432aa59877a3e39fb6 100644 (file)
@@ -269,8 +269,12 @@ AudioMappingView::paint_row_lines (wxGraphicsContext* gc)
 void
 AudioMappingView::paint_indicators (wxDC& dc)
 {
-       for (size_t x = 0; x < _output_channels.size(); ++x) {
-               for (size_t y = 0; y < _input_channels.size(); ++y) {
+       /* _{input,output}_channels and _map may not always be in sync, be careful here */
+       size_t const output = min(_output_channels.size(), _map.output_channels());
+       size_t const input = min(_input_channels.size(), _map.input_channels());
+
+       for (size_t x = 0; x < output; ++x) {
+               for (size_t y = 0; y < input; ++y) {
                        dc.SetBrush (*wxWHITE_BRUSH);
                        dc.DrawRectangle (
                                wxRect(