From 4aeef1e09e0f55adcac7a88cee8b0479d19be7a8 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 19 Dec 2018 17:12:43 -0700 Subject: [PATCH] pcbnew: Check for valid pointer before deref In legacy toolkit, we do not keep the corner pointers, so dereferencing causes crashes. Fixes: lp:1808852 * https://bugs.launchpad.net/kicad/+bug/1808852 --- pcbnew/class_zone.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index c0496a9019..945ef94e8c 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -207,8 +207,10 @@ public: int GetSelectedCorner() const { // Transform relative indices to global index - int globalIndex; - m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex ); + int globalIndex = -1; + + if( m_CornerSelection ) + m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex ); return globalIndex; }