From 0843fbf904ccb187f28a7f71fa53c69a419d7f63 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Aug 2021 11:58:47 +0100 Subject: [PATCH] Fix nullptr dereference. Fixes: lp:8996 * https://bugs.launchpad.net/kicad/+bug/8996 --- .../3d_render_raytracing/c3d_render_createscene.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index bf308024c2..dae9758190 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -449,6 +449,10 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter ) ++ii ) { PCB_LAYER_ID layer_id = static_cast(ii->first); + const CBVHCONTAINER2D *container2d = static_cast(ii->second); + + if( !container2d ) + continue; // Mask kayers are not processed here because they are a special case if( (layer_id == B_Mask) || (layer_id == F_Mask) ) @@ -509,7 +513,6 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter ) break; } - const CBVHCONTAINER2D *container2d = static_cast(ii->second); const LIST_OBJECT2D &listObject2d = container2d->GetList(); for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin(); @@ -655,6 +658,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter ) const CBVHCONTAINER2D *containerLayer2d = static_cast(ii->second); + if( !containerLayer2d ) + continue; + // Only get the Solder mask layers if( !((layer_id == B_Mask) || (layer_id == F_Mask)) ) continue;