clone45 / voxglitch

Modules for VCV Rack
GNU General Public License v3.0
98 stars 16 forks source link

Potential out of bounds array accesses #195

Closed cschol closed 1 year ago

cschol commented 1 year ago

I started running cppcheck as part of the integration process and cppcheck found these three potential issues.

I am not holding integration for now, but maybe check these out for the next release. Thanks.

Checking AutobreakStudio.cpp ...                                                                                                                                                                                                                                                                                      
AutobreakStudio/LcdTabsWidget.hpp:27:61: error: Array 'sequencer_displays[4]' accessed at index 5, which is out of bounds. [arrayIndexOutOfBounds]
            this->sequencer_displays[i] = sequencer_displays[i];                                                                                           
                                                            ^
AutobreakStudio/LcdTabsWidget.hpp:25:36: note: Assuming that condition 'i<NUMBER_OF_SEQUENCERS' is not redundant
        for (unsigned int i = 0; i < NUMBER_OF_SEQUENCERS; i++)
                                   ^     
AutobreakStudio/LcdTabsWidget.hpp:27:61: note: Array index out of bounds
            this->sequencer_displays[i] = sequencer_displays[i];
                                                            ^

and

Checking DigitalSequencer.cpp ...                                                                                                                          
DigitalSequencer/DigitalSequencer.hpp:162:88: error: Array 'this->voltage_sequencers[6]' accessed at index 6, which is out of bounds. [arrayIndexOutOfBounds]
      this->voltage_sequencers[dst_sequencer_index].setValue(i,this->voltage_sequencers[src_sequencer_index].getValue(i));
                                                                                       ^                                                                                                                                                                                                                              
DigitalSequencer/DigitalSequencer.hpp:163:82: error: Array 'this->gate_sequencers[6]' accessed at index 6, which is out of bounds. [arrayIndexOutOfBounds]
      this->gate_sequencers[dst_sequencer_index].setValue(i,this->gate_sequencers[src_sequencer_index].getValue(i));
                                                                                 ^                                                                

and

Checking DigitalSequencerXP.cpp ...                                                                                                                        
DigitalSequencerXP/DigitalSequencerXP.hpp:113:88: error: Array 'this->voltage_sequencers[16]' accessed at index 16, which is out of bounds. [arrayIndexOutOfBounds]
      this->voltage_sequencers[dst_sequencer_index].setValue(i,this->voltage_sequencers[src_sequencer_index].getValue(i));
                                                                                       ^                                                                                                                                                                                                                              
DigitalSequencerXP/DigitalSequencerXP.hpp:114:82: error: Array 'this->gate_sequencers[16]' accessed at index 16, which is out of bounds. [arrayIndexOutOfBounds]
      this->gate_sequencers[dst_sequencer_index].setValue(i,this->gate_sequencers[src_sequencer_index].getValue(i));
clone45 commented 1 year ago

Thank you! I'll have those fixed for the next release. Much appreciated!

clone45 commented 1 year ago

These have been fixed.