From 8f7c0735143cdcc14df4cc3457c96f7508563318 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 (cherry picked from commit 4aeef1e09e0f55adcac7a88cee8b0479d19be7a8) --- 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 7a3fa96984..769ff58dde 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -206,8 +206,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; }