From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30482 invoked by alias); 2 Mar 2011 20:40:33 -0000 Received: (qmail 30046 invoked by uid 22791); 2 Mar 2011 20:40:30 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Mar 2011 20:40:23 +0000 Received: from mailhost2.vmware.com (mailhost2.vmware.com [10.16.67.167]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 8AB3E27005; Wed, 2 Mar 2011 12:40:22 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost2.vmware.com (Postfix) with ESMTP id 81A458ED07; Wed, 2 Mar 2011 12:40:22 -0800 (PST) Message-ID: <4D6EAB36.2040804@vmware.com> Date: Wed, 02 Mar 2011 20:40:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: Tom Tromey CC: "gdb-patches@sourceware.org" , Phil Muldoon Subject: Re: [RFA] py-inferior.c, check return value of PyList_Append References: <4D6E8FFC.2090601@vmware.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------010106010101000903060109" 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-03/txt/msg00125.txt.bz2 This is a multi-part message in MIME format. --------------010106010101000903060109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 602 Tom Tromey wrote: >>>>>> "Michael" == Michael Snyder writes: > > Michael> Just making this up as I go, here, need a review. > Michael> 2011-03-02 Michael Snyder > Michael> * py-inferior.c (inferior_to_inferior_object): Check return > > Should be build_inferior_list, not inferior_to_inferior_object. > > This code is kind of bogus. I agree with your change, but then the > caller needs a change as well. It should do something like: > > if (iterate_over_inferiors (...)) > { > Py_DECREF (list); > return NULL; > } > > Tom Like this? --------------010106010101000903060109 Content-Type: text/plain; name="py-inferior2.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="py-inferior2.txt" Content-length: 1070 2011-03-02 Michael Snyder * python/py-inferior.c (build_inferior_list): Error out if PyList_Append fails. (gdbpy_inferiors): Error out if build_inferior_list fails. Index: python/py-inferior.c =================================================================== RCS file: /cvs/src/src/gdb/python/py-inferior.c,v retrieving revision 1.5 diff -u -p -u -p -r1.5 py-inferior.c --- python/py-inferior.c 4 Feb 2011 21:54:16 -0000 1.5 +++ python/py-inferior.c 2 Mar 2011 20:38:01 -0000 @@ -326,7 +326,9 @@ build_inferior_list (struct inferior *in PyObject *list = arg; PyObject *inferior = inferior_to_inferior_object (inf); - PyList_Append (list, inferior); + if (PyList_Append (list, inferior)) + return 1; + return 0; } @@ -343,7 +345,11 @@ gdbpy_inferiors (PyObject *unused, PyObj if (!list) return NULL; - iterate_over_inferiors (build_inferior_list, list); + if (iterate_over_inferiors (build_inferior_list, list)) + { + Py_DECREF (list); + return NULL; + } return PyList_AsTuple (list); } --------------010106010101000903060109--