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

Skip to content

Commit a78b627

Browse files
committed
Fix potential NULL pointer dereference in _imp_create_builtin
PyModule_GetDef() can return NULL. Let's check the return value properly like in the other five cases. CID 1299590
1 parent 4f29e75 commit a78b627

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Python/import.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
10771077
} else {
10781078
/* Remember pointer to module init function. */
10791079
def = PyModule_GetDef(mod);
1080+
if (def == NULL) {
1081+
Py_DECREF(name);
1082+
return NULL;
1083+
}
10801084
def->m_base.m_init = p->initfunc;
10811085
if (_PyImport_FixupExtensionObject(mod, name, name) < 0) {
10821086
Py_DECREF(name);

0 commit comments

Comments
 (0)