Browse Source

Prevent assert (and access violation) in wxWidgets.

(It directly dereferences the ArrayString with the
FilterIndex, without bounds checking it.)
pull/18/head
Jeff Young 3 months ago
parent
commit
238719184e
  1. 7
      gerbview/files.cpp
  2. 7
      pcbnew/footprint_libraries_utils.cpp

7
gerbview/files.cpp

@ -142,7 +142,12 @@ 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 );
dlg.SetFilterIndex( lastGerberFileWildcard );
wxArrayString dummy1, dummy2;
const int nWildcards = wxParseCommonDialogsFilter( dialogFiletypes, dummy1, dummy2 );
if( lastGerberFileWildcard >= 0 && lastGerberFileWildcard < nWildcards )
dlg.SetFilterIndex( lastGerberFileWildcard );
if( dlg.ShowModal() == wxID_CANCEL )
return false;

7
pcbnew/footprint_libraries_utils.cpp

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

Loading…
Cancel
Save