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

@@ -262,7 +262,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args)
#endif
try {
Py::Module module(PyImport_ImportModule("PartGui"),true);
if (!module.hasAttr("AttachEngineResources")) {
if (module.isNull() || !module.hasAttr("AttachEngineResources")) {
// in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods)
throw Py::RuntimeError("Gui is not up");//DeepSOIC: wanted to throw ImportError here, but it's not defined, so I don't know...
}
@@ -357,7 +357,7 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args)
try {
Py::Module module(PyImport_ImportModule("PartGui"),true);
if (!module.hasAttr("AttachEngineResources")) {
if (module.isNull() || !module.hasAttr("AttachEngineResources")) {
// in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods)
throw Py::RuntimeError("Gui is not up");//DeepSOIC: wanted to throw ImportError here, but it's not defined, so I don't know...
}