[docs] integer leak in refcount docs?

Georg Brandl georg at python.org
Sun Apr 14 11:45:40 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 24.01.2012 12:46, schrieb Daniel Shahaf:
> In <http://docs.python.org/c-api/intro.html#reference-count-details>, the
> example code reads:
> 
> 1	int 2	set_all(PyObject *target, PyObject *item) 3	{ 4	    int i, n; 5 6
> n = PyObject_Length(target); 7	    if (n < 0) 8	        return -1; 9
> for (i = 0; i < n; i++) { 10	        PyObject *index = PyInt_FromLong(i); 
> 11	        if (!index) 12	            return -1; 13	        if
> (PyObject_SetItem(target, index, item) < 0) 14	            return -1; 15
> Py_DECREF(index); 16	    } 17	    return 0; 18	}
> 
> Seems to me that line 14 leaks a reference to 'index'; that is:
> 
> @@ -13,2 +13,4 @@ -        if (PyObject_SetItem(target, index, item) < 0) +
> if (PyObject_SetItem(target, index, item) < 0) { +
> Py_DECREF(index); return -1; +        }
> 
> Does that make sense?

Hi Daniel,

thanks for the report, this is now fixed (belatedly) and should appear
online soon.

cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlFqesQACgkQN9GcIYhpnLDk6QCgmnKpwgHAuyx4kJ6N8rtKs07b
srAAoLB7aWMeMwNGXvAMfaazkEQetgB1
=cI6J
-----END PGP SIGNATURE-----


More information about the docs mailing list