diff options
author | Christian Heimes <christian@python.org> | 2016-09-08 22:25:03 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-09-08 22:25:03 (GMT) |
commit | a78b627e2b8ee464ecba3788725872d63f8a6b34 (patch) | |
tree | c64467c1e77dd8a2419b7b207523ff5f6b3df176 /Python/import.c | |
parent | 4f29e75289592991efcc65a96a2a4a995417b76e (diff) | |
download | cpython-a78b627e2b8ee464ecba3788725872d63f8a6b34.zip cpython-a78b627e2b8ee464ecba3788725872d63f8a6b34.tar.gz cpython-a78b627e2b8ee464ecba3788725872d63f8a6b34.tar.bz2 |
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
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c index 17188c2..dfdd940 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1077,6 +1077,10 @@ _imp_create_builtin(PyObject *module, PyObject *spec) } else { /* Remember pointer to module init function. */ def = PyModule_GetDef(mod); + if (def == NULL) { + Py_DECREF(name); + return NULL; + } def->m_base.m_init = p->initfunc; if (_PyImport_FixupExtensionObject(mod, name, name) < 0) { Py_DECREF(name); |