[New-bugs-announce] [issue18426] Crash when extension does not use PyModule_Create()

Ivan Johansen report at bugs.python.org
Thu Jul 11 08:36:51 CEST 2013


New submission from Ivan Johansen:

In Python/importdl.c around line 99 in the function _PyImport_LoadDynamicModule() you can find the code:
  def = PyModule_GetDef(m);
  def->m_base.m_init = p;

If the module m, which is returned from a newly imported extension, is not created by PyModule_Create() but in some other way then PyModule_GetDef(m) will return NULL. The next line will then dereference a NULL pointer and crash. 

I suggest a check for this is added:
  def = PyModule_GetDef(m);
  if(def != NULL) 
    def->m_base.m_init = p;

----------
messages: 192845
nosy: Padowan
priority: normal
severity: normal
status: open
title: Crash when extension does not use PyModule_Create()
type: crash
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18426>
_______________________________________


More information about the New-bugs-announce mailing list