1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-04 06:29:07 +02:00

Fix crash from bad SelectionToolbarMode

When out of range, it was indexing outside an array.  Now forced to be in range.
This commit is contained in:
James Crook 2017-05-30 12:38:25 +01:00
parent 545dbaf1cd
commit 7122877269

View File

@ -142,7 +142,16 @@ SelectionBar::SelectionBar()
// Audacity to fail.
mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
AudioIO::GetOptimalSupportedSampleRate());
#ifdef SEL_BUTTON_TITLES
mButtonTitles[0]=NULL;
mButtonTitles[1]=NULL;
mButtonTitles[2]=NULL;
#endif
mHyphen[0]=NULL;
mHyphen[1]=NULL;
mHyphen[2]=NULL;
// Selection mode of 0 means showing 'start' and 'end' only.
mSelectionMode = gPrefs->ReadLong(wxT("/SelectionToolbarMode"), 0);
}
@ -752,6 +761,18 @@ void SelectionBar::SelectionModeUpdated()
void SelectionBar::SetSelectionMode(int mode)
{
#ifdef SEL_BUTTON_TITLES
// With SEL_BUTTON_TITLES only modes 0 to 3 are supported,
// so fix up a mode that could have come from the config.
const int maxMode = 3;
#else
const int maxMode = 7;
#endif
if( mode > maxMode )
mode = 0;
if( mode < 0 )
mode = 0;
mSelectionMode = mode;
int id = mode + StartEndRadioID;