diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index 926775602..5d3b3d63f 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -175,8 +175,10 @@ void MidiIOPrefs::PopulateOrExchange( ShuttleGui & S ) { void MidiIOPrefs::OnHost(wxCommandEvent & e) { + wxString itemAtIndex; int index = mHost->GetCurrentSelection(); - wxString itemAtIndex = mHostNames.Item(index); + if (index >= 0 && index < mHostNames.Count()) + itemAtIndex = mHostNames.Item(index); int nDevices = Pm_CountDevices(); if (nDevices == 0) {