From 4486b0b6d66c583719377f0738ba6e3c85e1d2fe Mon Sep 17 00:00:00 2001 From: Ben Ellis Date: Tue, 7 Jul 2020 10:53:04 -0400 Subject: [PATCH] Fixed bounds checking. Not the root cause but keeps things from crashing. --- pcbnew/footprint_preview_panel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 39d34352e0..a79ab70e76 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -458,7 +458,8 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* 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 ); panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) );