]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix potential NULL pointer dereference in _imp_create_builtin
authorChristian Heimes <christian@python.org>
Thu, 8 Sep 2016 22:25:03 +0000 (00:25 +0200)
committerChristian Heimes <christian@python.org>
Thu, 8 Sep 2016 22:25:03 +0000 (00:25 +0200)
PyModule_GetDef() can return NULL. Let's check the return value properly
like in the other five cases.

CID 1299590

Python/import.c

index 17188c275a7e1fd8812d9f38342bd1ef96a2cd86..dfdd9409e5e119fe19fadfc09fb01d4a0a523733 100644 (file)
@@ -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);