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

Georg Brandl georg at python.org
Sat Sep 17 20:18:55 CEST 2011


-----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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)

iEYEARECAAYFAk505I8ACgkQN9GcIYhpnLAhswCdExyau/UBMlOrfPFf0Vzq/DXz
RrgAoJdg5npkJp2WwNzJH/CV/bzARUSJ
=c0Jk
-----END PGP SIGNATURE-----


More information about the docs mailing list