From 161dc9ce7eeaad8ea69a82f6d05a313541666307 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 31 Jul 2019 20:02:11 -0700 Subject: [PATCH] pcbnew: Fix VRML export checking In rare cases, the VRML triangulator may claim to work but return empty vectors. These cases need to be caught before we dereference the vector elements. Fixes: lp:1838448 * https://bugs.launchpad.net/kicad/+bug/1838448 --- pcbnew/exporters/export_vrml.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 3503a5d6d9..ef3a3cf00a 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1702,7 +1702,8 @@ static void create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX color std::vector< int > idxPlane; std::vector< int > idxSide; - if( !(*layer).Get2DTriangles( vertices, idxPlane, top_z, aTopPlane ) ) + if( !( *layer ).Get2DTriangles( vertices, idxPlane, top_z, aTopPlane ) || idxPlane.empty() + || idxSide.empty() ) { #ifdef DEBUG do { @@ -1788,7 +1789,8 @@ static void create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX color bottom_z = tmp; } - if( !(*layer).Get3DTriangles( vertices, idxPlane, idxSide, top_z, bottom_z ) ) + if( !( *layer ).Get3DTriangles( vertices, idxPlane, idxSide, top_z, bottom_z ) + || idxPlane.empty() || idxSide.empty() ) { #ifdef DEBUG do {