Merge pull request #1346 from ArchimedesPi/fixup-some-coverity-defects

Fix some defects from Coverity (WIP)
master
Marius Kintel 2015-05-15 15:45:11 -04:00
commit 5451fabcc1
5 changed files with 12 additions and 4 deletions

View File

@ -740,6 +740,7 @@ Response GeometryEvaluator::visit(State &state, const LinearExtrudeNode &node)
Polygon2d *p2d = dxf.toPolygon2d();
if (p2d) geometry = ClipperUtils::sanitize(*p2d);
delete p2d;
}
else {
geometry = applyToChildren2D(node, OPENSCAD_UNION);
@ -849,6 +850,7 @@ Response GeometryEvaluator::visit(State &state, const RotateExtrudeNode &node)
DxfData dxf(node.fn, node.fs, node.fa, node.filename, node.layername, node.origin_x, node.origin_y, node.scale);
Polygon2d *p2d = dxf.toPolygon2d();
if (p2d) geometry = ClipperUtils::sanitize(*p2d);
delete p2d;
}
else {
geometry = applyToChildren2D(node, OPENSCAD_UNION);
@ -954,6 +956,8 @@ Response GeometryEvaluator::visit(State &state, const ProjectionNode &node)
// Add correctly winded polygons to the main clipper
sumclipper.AddPaths(result, ClipperLib::ptSubject, true);
}
delete poly;
}
ClipperLib::PolyTree sumresult;
// This is key - without StrictlySimple, we tend to get self-intersecting results

View File

@ -237,6 +237,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx)
// this call alters ctx->xDisplay and ctx->openGLContext
// and ctx->xwindow if successfull
if (!create_glx_dummy_context( *ctx )) {
delete ctx;
return NULL;
}

View File

@ -236,14 +236,14 @@ AbstractNode *ControlModule::instantiate(const Context* /*ctx*/, const ModuleIns
return node;
}
else if (value->type() == Value::RANGE) {
AbstractNode* node = new AbstractNode(inst);
Value::RangeType range = value->toRange();
boost::uint32_t steps = range.nbsteps();
boost::uint32_t steps = range.nbsteps();
if (steps >= 10000) {
PRINTB("WARNING: Bad range parameter for children: too many elements (%lu).", steps);
return NULL;
}
for (Value::RangeType::iterator it = range.begin();it != range.end();it++) {
AbstractNode* node = new AbstractNode(inst);
for (Value::RangeType::iterator it = range.begin();it != range.end();it++) {
AbstractNode* childnode = getChild(Value(*it),modulectx); // with error cases
if (childnode==NULL) continue; // error
node->children.push_back(childnode);

View File

@ -424,6 +424,7 @@ void export_amf(const CGAL_Nef_polyhedron *root_N, std::ostream &output)
coords = strtok(NULL, " ");
output << " <z>" << coords << "</z>\r\n";
output << " </coordinates></vertex>\r\n";
delete[] chrs;
}
output << " </vertices>\r\n";
output << " <volume>\r\n";

View File

@ -82,7 +82,9 @@ bool report_glerror(const char * function)
{
GLenum tGLErr = glGetError();
if (tGLErr != GL_NO_ERROR) {
cerr << "OpenGL error 0x" << hex << tGLErr << ": " << gluErrorString(tGLErr) << " after " << function << endl;
std::ostringstream hexErr;
hexErr << hex << tGLErr;
cerr << "OpenGL error 0x" << hexErr.str() << ": " << gluErrorString(tGLErr) << " after " << function << endl;
return true;
}
return false;