Browse Source

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

pull/16/head
Ben Ellis 5 years ago
committed by Jon Evans
parent
commit
4486b0b6d6
  1. 3
      pcbnew/footprint_preview_panel.cpp

3
pcbnew/footprint_preview_panel.cpp

@ -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 ) );

Loading…
Cancel
Save