[Patches] [ python-Patches-587889 ] fix memory leak of tp_doc in typeobject

noreply@sourceforge.net noreply@sourceforge.net
Sun, 28 Jul 2002 20:10:04 -0700


Patches item #587889, was opened at 2002-07-28 23:10
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=587889&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Guido van Rossum (gvanrossum)
Summary: fix memory leak of tp_doc in typeobject

Initial Comment:
Attached is a patch which fixes a memory leak in
typeobject.c.  I would have checked this in, but there
was a line which concerned me in
Objects/structseq.c::PyStructSequence_InitType():343. 
In this function, it assigns the tp_doc from a
PyStructSequence_Desc* which is passed in.  I'm not
sure where this memory comes from, so I wasn't sure if
the patch would create problems.

The memory leak was found by using valgrind: 
http://developer.kde.org/~sewardj/

Another thing I saw was that it *may* be possible that
the __doc__ is not a string.  But in two places there
were PyString_FromString (1 was the macro).  The only
way I can see a non-string in tp_doc is from the
InitType function in structseq.  I haven't traced it
further, so if structseq can only have a string, there
shouldn't be a problem.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=587889&group_id=5470