From 961f5e599111f47641c39fe5e72b143f2f9f4861 Mon Sep 17 00:00:00 2001 From: clifford Date: Sat, 9 Jan 2010 12:23:49 +0000 Subject: [PATCH] Clifford Wolf: Fixed segfault on invalid polygon/polyhedron vetrex indices git-svn-id: http://svn.clifford.at/openscad/trunk@246 b57f626f-c46c-0410-a088-ec61d464b74c --- primitives.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/primitives.cc b/primitives.cc index 80e26b20..7e6a9e19 100644 --- a/primitives.cc +++ b/primitives.cc @@ -397,10 +397,11 @@ sphere_next_r2: p->append_poly(); for (int j=0; jvec.size(); j++) { int pt = triangles.vec[i]->vec[j]->num; - double px = points.vec[pt]->vec[0]->num; - double py = points.vec[pt]->vec[1]->num; - double pz = points.vec[pt]->vec[2]->num; - p->insert_vertex(px, py, pz); + if (pt < points.vec.size()) { + double px, py, pz; + if (points.vec[pt]->getv3(px, py, pz)) + p->insert_vertex(px, py, pz); + } } } } @@ -463,11 +464,15 @@ sphere_next_r2: { dd.paths.append(DxfData::Path()); for (int i=0; i 0) { + dd.paths.last().points.append(dd.paths.last().points.first()); + dd.paths.last().is_closed = true; } - dd.paths.last().points.append(dd.paths.last().points.first()); - dd.paths.last().is_closed = true; } else {