do some security checks to make sure Py::Module is valid

This commit is contained in:
wmayer
2019-06-03 17:57:52 +02:00
parent 9660b1fb1e
commit 85fddfc54a
3 changed files with 20 additions and 2 deletions

View File

@@ -1504,6 +1504,8 @@ MeshObject* MeshObject::createSphere(float radius, int sampling)
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Sphere"));
Py::Tuple args(2);
@@ -1529,6 +1531,8 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Ellipsoid"));
Py::Tuple args(3);
@@ -1555,6 +1559,8 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cylinder"));
Py::Tuple args(5);
@@ -1585,6 +1591,8 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cone"));
Py::Tuple args(6);
@@ -1616,6 +1624,8 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling)
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Toroid"));
Py::Tuple args(3);
@@ -1642,6 +1652,8 @@ MeshObject* MeshObject::createCube(float length, float width, float height)
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("Cube"));
Py::Tuple args(3);
@@ -1664,6 +1676,8 @@ MeshObject* MeshObject::createCube(float length, float width, float height, floa
Base::PyGILStateLocker lock;
try {
Py::Module module(PyImport_ImportModule("BuildRegularGeoms"),true);
if (module.isNull())
return 0;
Py::Dict dict = module.getDict();
Py::Callable call(dict.getItem("FineCube"));
Py::Tuple args(4);