[Python-checkins] cpython (merge 3.3 -> default): Issue #18426: Fix NULL pointer dereference in C extension import when

christian.heimes python-checkins at python.org
Thu Jul 11 11:24:14 CEST 2013


http://hg.python.org/cpython/rev/9fb3656b178a
changeset:   84537:9fb3656b178a
parent:      84535:70f55dc9d43f
parent:      84536:4343dfaca8e2
user:        Christian Heimes <christian at cheimes.de>
date:        Thu Jul 11 11:23:34 2013 +0200
summary:
  Issue #18426: Fix NULL pointer dereference in C extension import when
PyModule_GetDef() returns an error.

files:
  Misc/NEWS         |  3 +++
  Python/importdl.c |  2 ++
  2 files changed, 5 insertions(+), 0 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #18426: Fix NULL pointer dereference in C extension import when
+  PyModule_GetDef() returns an error.
+
 - Issue #17206: On Windows, increase the stack size from 2 MB to 4.2 MB to fix
   a stack overflow in the marshal module (fix a crash in test_marshal).
   Patch written by Jeremy Kloth.
diff --git a/Python/importdl.c b/Python/importdl.c
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -97,6 +97,8 @@
 
     /* Remember pointer to module init function. */
     def = PyModule_GetDef(m);
+    if (def == NULL)
+        goto error;
     def->m_base.m_init = p;
 
     /* Remember the filename as the __file__ attribute */

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


More information about the Python-checkins mailing list