Mesh: Fix several coverity issues:

* CID 350557: Out-of-bounds read (false-positive)
* CID 316517: Uninitialized scalar variable
* CID 316519: Uninitialized scalar variable
* CID 316547: Uninitialized scalar variable
* CID 316556: Uninitialized scalar variable
* CID 350614: Uncaught exception
* CID 350606: Uncaught exception
* CID 332681: Using invalid iterator
This commit is contained in:
wmayer
2022-03-13 14:58:14 +01:00
parent 76d1180283
commit f6f21f4fa6
3 changed files with 19 additions and 6 deletions

View File

@@ -111,7 +111,8 @@ int Exporter::addObject(App::DocumentObject *obj, float tol)
it = meshCache.emplace(linked,
static_cast<Mesh::Feature*>(linked)->Mesh.getValue()).first;
it->second.setTransform(Base::Matrix4D());
} else {
}
else {
Base::PyGILStateLocker lock;
PyObject *pyobj = nullptr;
linked->getSubObject("", &pyobj, nullptr, false);
@@ -128,10 +129,14 @@ int Exporter::addObject(App::DocumentObject *obj, float tol)
Py_DECREF(pyobj);
}
}
MeshObject mesh(it->second);
mesh.transformGeometry(matrix);
if (addMesh(sobj->Label.getValue(), mesh))
++count;
// Add a new mesh
if (it != meshCache.end()) {
MeshObject mesh(it->second);
mesh.transformGeometry(matrix);
if (addMesh(sobj->Label.getValue(), mesh))
++count;
}
}
return count;
}