From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25507 invoked by alias); 26 Feb 2009 08:45:18 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 25405 invoked by uid 9514); 26 Feb 2009 08:45:17 -0000 Date: Thu, 26 Feb 2009 08:45:00 -0000 Message-ID: <20090226084517.25390.qmail@sourceware.org> From: pmuldoon@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-python: [python] python-utils.c (python_string_to_unicode): Always return a new reference. X-Git-Refname: refs/heads/archer-tromey-python X-Git-Reftype: branch X-Git-Oldrev: 9f534e722211caffa7caef5cd11c5da2ac24f6c4 X-Git-Newrev: b5235efef9aa1d619d8a5defc5aa1219dff76d3d X-SW-Source: 2009-q1/txt/msg00194.txt.bz2 List-Id: The branch, archer-tromey-python has been updated via b5235efef9aa1d619d8a5defc5aa1219dff76d3d (commit) from 9f534e722211caffa7caef5cd11c5da2ac24f6c4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit b5235efef9aa1d619d8a5defc5aa1219dff76d3d Author: Phil Muldoon Date: Thu Feb 26 08:44:03 2009 +0000 [python] python-utils.c (python_string_to_unicode): Always return a new reference. 2009-02-26 Phil Muldoon * 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. ----------------------------------------------------------------------- Summary of changes: gdb/python/python-utils.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) First 500 lines of diff: diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c index c6c305f..f9c9486 100644 --- a/gdb/python/python-utils.c +++ b/gdb/python/python-utils.c @@ -82,7 +82,11 @@ python_string_to_unicode (PyObject *obj) /* If obj is already a unicode string, just return it. I wish life was always that simple... */ if (PyUnicode_Check (obj)) - unicode_str = obj; + { + unicode_str = obj; + Py_INCREF (obj); + } + else if (PyString_Check (obj)) unicode_str = PyUnicode_FromEncodedObject (obj, host_charset (), NULL); else @@ -137,12 +141,15 @@ char * python_string_to_target_string (PyObject *obj) { PyObject *str; + char *result; str = python_string_to_unicode (obj); if (str == NULL) return NULL; - return unicode_to_target_string (str); + result = unicode_to_target_string (str); + Py_DECREF (str); + return result; } /* Converts a python string (8-bit or unicode) to a target string in @@ -153,12 +160,15 @@ char * python_string_to_host_string (PyObject *obj) { PyObject *str; + char *result; str = python_string_to_unicode (obj); if (str == NULL) return NULL; - return unicode_to_encoded_string (str, host_charset ()); + result = unicode_to_encoded_string (str, host_charset ()); + Py_DECREF (str); + return result; } /* Converts a target string of LENGTH bytes in the target's charset to a hooks/post-receive -- Repository for Project Archer.