From d12e8479f223dcd0c59ebaa999fb69afa3f40c2b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 24 Jan 2020 10:13:18 +0100 Subject: [PATCH] Pcbnew: fix crash when trying to select the previous copper layer. The function that calculates the previous layer id was using a illegal value in some cases. Fixes #3805 https://gitlab.com/kicad/code/kicad/issues/3805 --- pcbnew/tools/pcbnew_control.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index a04f549248..0c034266b9 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -363,7 +363,8 @@ int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent ) while( startLayer != --layer ) { - if( brd->IsLayerVisible( static_cast( layer ) ) && IsCopperLayer( layer ) ) + if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu) + && brd->IsLayerVisible( static_cast( layer ) ) ) break; if( layer <= F_Cu )