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

Skip to content

Commit 09ca794

Browse files
committed
Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
CID 486649
1 parent 0bd447f commit 09ca794

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
@@ -553,7 +553,10 @@ _PyImport_FindExtensionObject(PyObject *name, PyObject *filename)
553553
mod = def->m_base.m_init();
554554
if (mod == NULL)
555555
return NULL;
556-
PyDict_SetItem(PyImport_GetModuleDict(), name, mod);
556+
if (PyDict_SetItem(PyImport_GetModuleDict(), name, mod) == -1) {
557+
Py_DECREF(mod);
558+
return NULL;
559+
}
557560
Py_DECREF(mod);
558561
}
559562
if (_PyState_AddModule(mod, def) < 0) {

0 commit comments

Comments
 (0)