[Python-checkins] cpython (merge 3.3 -> default): Add missing check of PyDict_SetItem()'s return value in

christian.heimes python-checkins at python.org
Sat Jul 20 14:52:51 CEST 2013


http://hg.python.org/cpython/rev/92e27be3dd62
changeset:   84729:92e27be3dd62
parent:      84727:29c6fe41e7f1
parent:      84728:80a5c2c2fb8a
user:        Christian Heimes <christian at cheimes.de>
date:        Sat Jul 20 14:52:18 2013 +0200
summary:
  Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
CID 486649

files:
  Python/import.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -585,7 +585,10 @@
         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) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list