]> granicus.if.org Git - python/commitdiff
Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
authorChristian Heimes <christian@cheimes.de>
Sat, 20 Jul 2013 12:51:53 +0000 (14:51 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 20 Jul 2013 12:51:53 +0000 (14:51 +0200)
CID 486649

Python/import.c

index 26261e191488be57ff13e56631e137a8cb94d730..e91cef83ff175aa410a60ba85a9a8df0232dd7a7 100644 (file)
@@ -553,7 +553,10 @@ _PyImport_FindExtensionObject(PyObject *name, PyObject *filename)
         mod = def->m_base.m_init();
         if (mod == NULL)
             return NULL;
-        PyDict_SetItem(PyImport_GetModuleDict(), name, mod);
+        if (PyDict_SetItem(PyImport_GetModuleDict(), name, mod) == -1) {
+            Py_DECREF(mod);
+            return NULL;
+        }
         Py_DECREF(mod);
     }
     if (_PyState_AddModule(mod, def) < 0) {