_namemapper: check error from PyImport_ImportModule
Bogdano Arendartchuk <[email protected]>
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
Hello,
An exception raised by __import__ could result in a segfault by
_namemapper because it doesn't check the returned pointer from
PyImport_ImportModule.
Would it be possible to add something like the following check:
--- a/src/_namemapper.c
+++ b/src/_namemapper.c
@@ -514,7 +514,9 @@ init_namemapper(void)
TooManyPeriods =
PyErr_NewException("NameMapper.TooManyPeriodsInName",NULL,NULL);
PyDict_SetItemString(d, "NotFound", NotFound);
PyDict_SetItemString(d, "TooManyPeriodsInName", TooManyPeriods);
- pprintMod = PyImport_ImportModule("pprint"); /* error check this */
+ pprintMod = PyImport_ImportModule("pprint");
+ if (!pprintMod)
+ return;
pprintMod_pformat = PyObject_GetAttrString(pprintMod, "pformat");
Py_DECREF(pprintMod);
/* check for errors */
--
Bogdano Arendartchuk
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get