From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27885 invoked by alias); 20 Oct 2011 14:23:44 -0000 Received: (qmail 27875 invoked by uid 22791); 20 Oct 2011 14:23:43 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Oct 2011 14:23:23 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9KENNTn028082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Oct 2011 10:23:23 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9KENMih016011 for ; Thu, 20 Oct 2011 10:23:22 -0400 From: Phil Muldoon To: gdb-patches@sourceware.org Subject: [python] [patch] PR python/13310 Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Thu, 20 Oct 2011 14:28:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00557.txt.bz2 David Malcolm's GCC plug-in found another bug where we lose a reference. The first case is we do not decrement "result" after a call to "python_string_to_host_string". That function returns a xstrdup of the string PyObject contents, and so "result" does not need to be preserved. The second case is where we type-check the object, and if it is not a Python string we set an exception without decrementing "result". OK? Cheers, Phil -- 2011-10-20 Phil Muldoon PR python/13310 * python/py-param.c (call_doc_function): Correctly deference on function exit. -- diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index d68d8fb..fe31cd1 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -331,6 +331,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg) if (gdbpy_is_string (result)) { data = python_string_to_host_string (result); + Py_DECREF (result); if (! data) return NULL; } @@ -338,6 +339,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg) { PyErr_SetString (PyExc_RuntimeError, _("Parameter must return a string value.")); + Py_DECREF (result); return NULL; }