From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24913 invoked by alias); 19 Oct 2010 20:11:20 -0000 Received: (qmail 24891 invoked by uid 22791); 19 Oct 2010 20:11:18 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_MD,T_RP_MATCHES_RCVD 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; Tue, 19 Oct 2010 20:11:12 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JKBAQx025499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 16:11:10 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9JKBAtl017398; Tue, 19 Oct 2010 16:11:10 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9JKB9KV024975; Tue, 19 Oct 2010 16:11:09 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 27AC7379188; Tue, 19 Oct 2010 14:11:08 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: fix latent leak in cmdpy_function Date: Tue, 19 Oct 2010 20:11:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-10/txt/msg00300.txt.bz2 I'm checking this in. PyErr_Fetch gives the caller a reference to each returned object. This patch changes cmdpy_function to decref the objects in the branch where PyErr_Restore is not called. Built and regtested on x86-64 (compile farm). Tom 2010-10-19 Tom Tromey * python/py-cmd.c (cmdpy_function): Unreference exception state. Index: python/py-cmd.c =================================================================== RCS file: /cvs/src/src/gdb/python/py-cmd.c,v retrieving revision 1.8 diff -u -r1.8 py-cmd.c --- python/py-cmd.c 13 Oct 2010 13:24:39 -0000 1.8 +++ python/py-cmd.c 19 Oct 2010 20:09:01 -0000 @@ -192,7 +192,12 @@ error (_("Error occurred in Python command.")); } else - error ("%s", msg); + { + Py_XDECREF (ptype); + Py_XDECREF (pvalue); + Py_XDECREF (ptraceback); + error ("%s", msg); + } } Py_DECREF (result);