From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24591 invoked by alias); 14 Dec 2010 21:41:55 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 24515 invoked by uid 22791); 14 Dec 2010 21:41:54 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org From: Tom Tromey To: Project Archer Subject: [[inferior events] partial cleanup for copy_py_list Date: Tue, 14 Dec 2010 21:41:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2010-q4/txt/msg00037.txt.bz2 This fixes some issues in copy_py_list, but not all. The patch changes it to check PyList_Append. I think it should probably use an iterator to go through the list. Otherwise it is susceptible to a bug where another thread changes the list while we are iterating over it. Still, ok to push in this form? Tom diff --git a/gdb/python/python.c b/gdb/python/python.c index 7c686d3..34e5bf8 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -163,10 +163,11 @@ compute_python_string (struct command_line *l) } /* Returns a a copy of the give LIST. - Creates a new reference which must be handeld by the caller. */ + Creates a new reference which must be handled by the caller. */ PyObject * -copy_py_list (PyObject *list){ +copy_py_list (PyObject *list) +{ int i; PyObject *new_list = PyList_New (0); @@ -174,7 +175,11 @@ copy_py_list (PyObject *list){ return NULL; for (i = 0; i < PyList_Size (list); i++) - PyList_Append (new_list, PyList_GET_ITEM (list, i)); + if (PyList_Append (new_list, PyList_GET_ITEM (list, i)) < 0) + { + Py_DECREF (new_list); + return NULL; + } return new_list; }