From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28721 invoked by alias); 21 May 2013 20:56:34 -0000 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 Received: (qmail 28672 invoked by uid 89); 21 May 2013 20:56:28 -0000 X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 21 May 2013 20:56:28 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4LKuRdF027859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 May 2013 16:56:27 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4LKuPZZ011724; Tue, 21 May 2013 16:56:25 -0400 Message-ID: <519BDF78.3000000@redhat.com> Date: Tue, 21 May 2013 20:56:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Tom Tromey CC: Jan Kratochvil , gdb-patches@sourceware.org Subject: [COMMIT] py_decref: Don't check for NULL before calling Py_DECREF. (was: Re: [patch] Compilation regression with python-2.6) References: <87ehe638ww.fsf@fleche.redhat.com> <8761ziy43f.fsf@fleche.redhat.com> <20130521075803.GA404@host2.jankratochvil.net> <519B9B54.9090907@redhat.com> <20130521161400.GA2763@host2.jankratochvil.net> <519B9F9A.9070600@redhat.com> <877gisl275.fsf@fleche.redhat.com> <519BA558.4030100@redhat.com> <87txlwjl1p.fsf@fleche.redhat.com> In-Reply-To: <87txlwjl1p.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-05/txt/msg00791.txt.bz2 On 05/21/2013 06:32 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> If you think this is not good, then I'll just file a PR. > > It is totally fine. Please check it in. Thanks. Done. --------- Subject: py_decref: Don't check for NULL before calling Py_DECREF. The only difference between Py_DECREF and Py_XDECREF is that the latter allows passing in a NULL object, while the former prohibits it. Given that, it's natural to expect the same from py_decref vs py_xdecref. gdb/ 2013-05-21 Pedro Alves * python/py-prettyprint.c (apply_val_pretty_printer): Check whether PRINTER is NULL before installing a Py_DECREF cleanup. * python/py-utils.c (py_decref): Don't check for NULL before calling Py_DECREF. --- gdb/python/py-prettyprint.c | 6 +++++- gdb/python/py-utils.c | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 8c45cd6..8fa2f42 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -735,8 +735,12 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, /* Find the constructor. */ printer = find_pretty_printer (val_obj); Py_DECREF (val_obj); + + if (printer == NULL) + goto done; + make_cleanup_py_decref (printer); - if (! printer || printer == Py_None) + if (printer == Py_None) goto done; /* If we are printing a map, we want some special formatting. */ diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 80bacf7..7c7c5ca 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -31,8 +31,7 @@ py_decref (void *p) { PyObject *py = p; - if (py) - Py_DECREF (py); + Py_DECREF (py); } /* Return a new cleanup which will decrement the Python object's