From 5a7982161d7b8be80d3b5f48553e239919b3a89f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 15 Dec 2022 14:27:14 +0100 Subject: [PATCH] python scripting: fix crash due to a null pointer use. Fixes #13160 https://gitlab.com/kicad/code/kicad/issues/13160 --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 479d73d5d3..6ef468779a 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -493,7 +493,7 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, engine->SetViolationHandler( [&]( const std::shared_ptr& aItem, VECTOR2D aPos, int aLayer ) { - if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT + if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT || aItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT || aItem->GetErrorCode() == DRCE_NET_CONFLICT ) @@ -533,7 +533,8 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, for( const std::shared_ptr& item : violations ) { - SEVERITY severity = item->GetParent()->GetSeverity(); + SEVERITY severity = item->GetParent() ? item->GetParent()->GetSeverity() + : RPT_SEVERITY_UNDEFINED; fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) ); }