Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74ba26a

Browse files
committed
Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
CID 486649
2 parents 895bdfb + 09ca794 commit 74ba26a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Python/import.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ _PyImport_FindExtensionObject(PyObject *name, PyObject *filename)
585585
mod = def->m_base.m_init();
586586
if (mod == NULL)
587587
return NULL;
588-
PyDict_SetItem(PyImport_GetModuleDict(), name, mod);
588+
if (PyDict_SetItem(PyImport_GetModuleDict(), name, mod) == -1) {
589+
Py_DECREF(mod);
590+
return NULL;
591+
}
589592
Py_DECREF(mod);
590593
}
591594
if (_PyState_AddModule(mod, def) < 0) {

0 commit comments

Comments
 (0)