Re: _namemapper: check error from PyImport_ImportModule

"R. Tyler Ballance" <[email protected]>
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
On Sun, Jun 07, 2009 at 03:46:31PM -0300, Bogdano Arendartchuk wrote:
> 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 */

For what it's worth, this was committed and pushed in the next branch (c6edfa3), 
I still however would appreciate a proper regression test using PyUnit (you can
refer to some examples in src/Tests/Regressions.py). 

This will ship with v2.2.2 in a couple weeks

-- 
-R. Tyler Ballance
Slide, Inc.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkoukaIACgkQFCbH3D9R4W9QkwCgrWLqC++1EHZxobl7IGm9ekKD
J7AAnRdEChqtSuuvjNzkHpKvb8W9tmpp
=KOM6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.