[Python-bugs-list] [ python-Bugs-520045 ] memory leak in descr_new

noreply@sourceforge.net noreply@sourceforge.net
Tue, 19 Feb 2002 10:14:59 -0800


Bugs item #520045, was opened at 2002-02-19 08:39
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=520045&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
>Priority: 1
Submitted By: Steve Glaser (sglaser)
Assigned to: Nobody/Anonymous (nobody)
Summary: memory leak in descr_new

Initial Comment:
I was trying to understand how the new descriptor 
stuff worked and ran across this.

It's unlikely that anyone ever got caught by this 
since it's a leak only when you InternFromString fails 
and you want to actually delete a type.

Current CVS tree doesn't fix this (but this is my 
first time on sourceforge so I might not be looking in 
the right place).

static PyDescrObject *
descr_new(PyTypeObject *descrtype, PyTypeObject *type, 
char *name)
{
	PyDescrObject *descr;

	descr = (PyDescrObject *)PyType_GenericAlloc
(descrtype, 0);
	if (descr != NULL) {
		Py_XINCREF(type);
		descr->d_type = type;
		descr->d_name = 
PyString_InternFromString(name);
		if (descr->d_name == NULL) {
			Py_DECREF(descr);
                        Py_XDECREF(type);  // BUGFIX
			descr = NULL;
		}
	}
	return descr;
}


----------------------------------------------------------------------

>Comment By: Steve Glaser (sglaser)
Date: 2002-02-19 10:14

Message:
Logged In: YES 
user_id=463610

as rose ann adanna would say never mind.

I misread the code so the DECREF just before my "bugfix" 
does the trick.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=520045&group_id=5470