[docs] Memory leak in sample "Noddy" extension module code

Paul Koning paulkoning at comcast.net
Mon Sep 19 02:52:53 CEST 2011


On Sep 17, 2011, at 2:18 PM, Georg Brandl wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Am 12.09.2011 16:51, schrieb Paul Koning:
>> Gentlepeople,
>> 
>> There's a memory leak in the sample code for the Noddy extension module in 
>> the "Extending and Embedding" manual for 2.7.2.  Consider for example
>> section 2.1.2, page 36 in the US page size PDF file, function
>> Noddy_name().
>> 
>> There are two places where Py_DECREF(format) is needed, and both are
>> missing. One is in the error handler for the creation of the "args" object.
>> The other is after the call to PyString_Format(format,args).
>> 
>> The error is repeated a couple of times in the assorted variants of the
>> Noddy module example.
> 
> Hey Paul,
> 
> I think the examples are correct: "format" is declared static and only
> initialized once per process.  Therefore it shouldn't be decref'd.
> 
> Georg

Sure enough.  That was a bit confusing; perhaps a comment would help.

	paul




More information about the docs mailing list