From 63c1154f8e434da1988dccac4101a51271083fe2 Mon Sep 17 00:00:00 2001 From: kintel Date: Wed, 10 Feb 2010 15:26:15 +0000 Subject: Fixed crash when using negative array indices git-svn-id: http://svn.clifford.at/openscad/trunk@433 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/OpenSCAD-polygons.graffle b/doc/OpenSCAD-polygons.graffle index c8c1a94..1dae615 100644 Binary files a/doc/OpenSCAD-polygons.graffle and b/doc/OpenSCAD-polygons.graffle differ diff --git a/doc/OpenSCAD-polygons.pdf b/doc/OpenSCAD-polygons.pdf index bf00397..150024d 100644 Binary files a/doc/OpenSCAD-polygons.pdf and b/doc/OpenSCAD-polygons.pdf differ diff --git a/doc/TODO.txt b/doc/TODO.txt index c0a25d4..3f62c80 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -9,7 +9,7 @@ CRASH BUGS ---------- o Broken polyhedron() entities are not correctly detected and cause CGAL segfaults o Export STL: Exports existing CGAL model even though the current model is changed, but not CGAL rendered -o Negative array indices causes crash: v=[0,1,2]; a=v[-1]; + USER INTERFACE -------------- @@ -66,7 +66,7 @@ o Computation o Misc - Reload and compile: Ask for confirmation if file is locally edited (make this configurable in preferences?) - - Save: Ask for confirmation if file has been externaly changed + - Save: Ask for confirmation if file has been externally changed - Rename OpenCSG and CGAL to smth. not specific to the underlying libraries (e.g Preview, Render) @@ -127,7 +127,7 @@ o Refactor from MainWindow: o C++-ify - Use smart pointers where it makes sense (e.g. instead of homegrown refcount, and to get memory ownership under control) - - Use static_cast instead of C-style casts + - Use static_cast/dynamic_cast instead of C-style casts o dxflinextrude and dxfrotextrude could share code o Consider decoupling DXF-specific functionality from the 2D subsystem o Make the interfaces from OpenSCAD and OpenCSG and CGAL cleaner to facilitate diff --git a/src/expr.cc b/src/expr.cc index 35fc776..23bcc32 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -81,7 +81,7 @@ Value Expression::evaluate(const Context *context) const Value v2 = children[1]->evaluate(context); if (v1.type == Value::VECTOR && v2.type == Value::NUMBER) { int i = (int)(v2.num); - if (i < v1.vec.size()) + if (i >= 0 && i < v1.vec.size()) return *v1.vec[i]; } return Value(); -- cgit v0.10.1