Prevent assert (and access violation) in wxWidgets.

(It directly dereferences the ArrayString with the
FilterIndex, without bounds checking it.)
This commit is contained in:
Jeff Young 2025-06-29 18:43:53 -06:00
parent 82fd8623eb
commit 238719184e
2 changed files with 12 additions and 2 deletions

View File

@ -142,6 +142,11 @@ bool GERBVIEW_FRAME::LoadFileOrShowDialog( const wxString& aFileName,
wxFileDialog dlg( this, dialogTitle, currentPath, filename.GetFullName(), dialogFiletypes,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR );
wxArrayString dummy1, dummy2;
const int nWildcards = wxParseCommonDialogsFilter( dialogFiletypes, dummy1, dummy2 );
if( lastGerberFileWildcard >= 0 && lastGerberFileWildcard < nWildcards )
dlg.SetFilterIndex( lastGerberFileWildcard );
if( dlg.ShowModal() == wxID_CANCEL )

View File

@ -114,6 +114,7 @@ FOOTPRINT* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
}
wxString allWildcardsStr;
for( const wxString& wildcard : allWildcardsSet )
allWildcardsStr << wildcard;
@ -123,6 +124,10 @@ FOOTPRINT* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
wxFileDialog dlg( this, _( "Import Footprint" ), m_mruPath, wxEmptyString, fileFiltersStr,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
wxArrayString dummy1, dummy2;
const int nWildcards = wxParseCommonDialogsFilter( fileFiltersStr, dummy1, dummy2 );
if( lastFilterIndex >= 0 && lastFilterIndex < nWildcards )
dlg.SetFilterIndex( lastFilterIndex );
if( dlg.ShowModal() == wxID_CANCEL )