[python] Fix two memory leaks

Phil Muldoon pmuldoon@redhat.com
Wed Feb 25 18:29:00 GMT 2009


I'm submitting the first fix here for continuity, even though the 
unicode_decref.patch case was submitted in this message:

http://sources.redhat.com/ml/archer/2009-q1/msg00240.html

And reviewed in this one:

http://sources.redhat.com/ml/archer/2009-q1/msg00248.html

The unicode_decref patch changes the: 
"python-utils.c/python_string_to_unicode" function to always return a 
new reference.  Previously it would return either a new or borrowed 
reference, which created ambiguity to the callers about clean-up.  This 
resulted in a memory leak in some unicode string handling operations in 
GDB Python.

The second patch is a straightforward addition of a variable dereference 
inside the function:  "python.c/apply_val_pretty_printer". This value 
object was never being dereferenced.

Hopefully I'll have the two other areas that I am investigating 
submitted soon. These fixes are not inter-dependent, so I decided to 
submit them as soon as possible.

Regards

Phil

ChangeLog

2009-02-25  Phil Muldoon  <pmuldoon@redhat.com>

    * python/python.c (apply_val_pretty_printer): Clean-up value
    instance after search.
    * python/python-utils.c (python_string_to_unicode): Always return
    a new reference.
    (python_string_to_target_string): Decrement transient python
    instance.
    (python_string_to_host_string): Likewise.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: unicode_decref.patch
Type: text/x-patch
Size: 1401 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/archer/attachments/20090225/01fa5ec0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: value_decr.patch
Type: text/x-patch
Size: 426 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/archer/attachments/20090225/01fa5ec0/attachment-0001.bin>


More information about the Archer mailing list