Skip to content

Commit bc06091

Browse files
Fix nullptr crash in the OpenEXR Python module.
PyErr_NewException() returns null at runtime so guard against it. It's unclear why the function returns null but guarding against it doesn't cause any other known issues aside from the loss of the old `OpenEXR.error` exception class.
1 parent be70a89 commit bc06091

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wrappers/python/PyOpenEXR_old.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,11 @@ init_OpenEXR_old(PyObject* module)
15721572
PyModule_AddObject (module, "OutputFile", (PyObject*) &OutputFile_Type);
15731573

15741574
OpenEXR_error = PyErr_NewException ((char*) "OpenEXR.error", NULL, NULL);
1575-
PyDict_SetItemString (moduleDict, "error", OpenEXR_error);
1576-
Py_DECREF (OpenEXR_error);
1575+
if (OpenEXR_error)
1576+
{
1577+
PyDict_SetItemString (moduleDict, "error", OpenEXR_error);
1578+
Py_DECREF (OpenEXR_error);
1579+
}
15771580

15781581
PyObject *item;
15791582

0 commit comments

Comments
 (0)