BUG: classobject.c

M.-A. Lemburg mal at lemburg.com
Sun Oct 10 08:58:21 EDT 1999


Adrian Eyre wrote:
> 
> 3 lines starting at 1554:
>                 funcname = PyObject_GetAttrString(func,"__name__");
>                 if (funcname == NULL)
>                         PyErr_Clear();
> 
> should be (perhaps - not sure if this will leak or not):
>                 funcname = PyObject_GetAttrString(func,"__name__");
>                 if (funcname == NULL)
>                         PyErr_Clear();
>                 else
>                         Py_INCREF(funcname);

The PyObject_* APIs return object references with incremented refcount.
You don't need the Py_INCREF here -- it would cause a memory leak.

> or else - line 1562:
>         Py_XDECREF(funcname);
> 
> causes an free'd memory read (fname) at line 1567:
>         if (self == NULL)
>                 sprintf(buf, "<unbound method %.100s.%.100s>", fcname, fname);
> 
> --------------------------------------------
> Adrian Eyre <mailto:a.eyre at optichrome.com>
> Optichrome Computer Solutions Ltd
> Maybury Road, Woking, Surrey, GU21 5HX, UK
> Tel: +44 1483 740 233  Fax: +44 1483 760 644
> http://www.optichrome.com
> --------------------------------------------

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                    82 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/





More information about the Python-list mailing list