# HG changeset patch # User Chris Cannam # Date 1481562076 0 # Node ID 13eb1d55f129264d56507a3dfa37fc3b0052d356 # Parent 65d34b07de85864bac19aa2b4322591bdf27138b Avoid overflowing vector if number of devices becomes smaller diff -r 65d34b07de85 -r 13eb1d55f129 main/PreferencesDialog.cpp --- a/main/PreferencesDialog.cpp Mon Dec 12 15:46:53 2016 +0000 +++ b/main/PreferencesDialog.cpp Mon Dec 12 17:01:16 2016 +0000 @@ -875,6 +875,9 @@ vector names = breakfastquay::AudioFactory::getImplementationNames(); string implementationName; + if (m_audioImplementation > int(names.size())) { + m_audioImplementation = 0; + } if (m_audioImplementation > 0) { implementationName = names[m_audioImplementation-1]; } @@ -887,6 +890,9 @@ names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName); string deviceName; + if (m_audioPlaybackDevice > int(names.size())) { + m_audioPlaybackDevice = 0; + } if (m_audioPlaybackDevice > 0) { deviceName = names[m_audioPlaybackDevice-1]; } @@ -894,6 +900,9 @@ names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName); deviceName = ""; + if (m_audioRecordDevice > int(names.size())) { + m_audioRecordDevice = 0; + } if (m_audioRecordDevice > 0) { deviceName = names[m_audioRecordDevice-1]; } @@ -922,6 +931,7 @@ if (m_audioDeviceChanged) { emit audioDeviceChanged(); + m_audioDeviceChanged = false; } }