Fixed bounds checking. Not the root cause but keeps things from crashing.

This commit is contained in:
Ben Ellis 2020-07-07 10:53:04 -04:00 committed by Jon Evans
parent d248736f08
commit 4486b0b6d6
1 changed files with 2 additions and 1 deletions

View File

@ -458,7 +458,8 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
panel->GetGAL()->SetGridVisibility( gridCfg.show ); panel->GetGAL()->SetGridVisibility( gridCfg.show );
int gridIdx = std::max( 0, std::min( gridCfg.last_size_idx, (int) gridCfg.sizes.size() ) ); //Bounds checking cannot include number of elements as an index!
int gridIdx = std::max( 0, std::min( gridCfg.last_size_idx, (int) gridCfg.sizes.size() - 1 ) );
int gridSize = (int) ValueFromString( EDA_UNITS::INCHES, gridCfg.sizes[ gridIdx ], true ); int gridSize = (int) ValueFromString( EDA_UNITS::INCHES, gridCfg.sizes[ gridIdx ], true );
panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) ); panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) );