From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4759 invoked by alias); 1 Dec 2010 22:58:37 -0000 Received: (qmail 4744 invoked by uid 22791); 1 Dec 2010 22:58:36 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Wed, 01 Dec 2010 22:58:31 +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 oB1MwUpN004349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 1 Dec 2010 17:58:30 -0500 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB1MwRlm012923 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Wed, 1 Dec 2010 17:58:29 -0500 Message-ID: <4CF6D1E3.6070709@redhat.com> Date: Wed, 01 Dec 2010 22:58:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.4 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [RFA] Cleanup in find_method Content-Type: multipart/mixed; boundary="------------050806080405070303070809" 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: 2010-12/txt/msg00009.txt.bz2 This is a multi-part message in MIME format. --------------050806080405070303070809 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 593 Hi, While bashing my brains against decode_compound today, I noticed that name canonicalization in find_method is done inside a loop, and it doesn't need to be. I've also taken a small liberty, adding a cleanup for it, just in case something freaky happens inside find_function_start_sal. I don't think that this function can fail in this specific case, but call me paranoid. It doesn't hurt. Comments? Keith ChangeLog 2010-12-01 Keith Seitz * linespec.c (find_method): Move name canonicalization outside the loop. Be paranoid and use a cleanup. --------------050806080405070303070809 Content-Type: text/plain; name="find_method-canon-cleanup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="find_method-canon-cleanup.patch" Content-length: 1380 Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.104 diff -u -p -r1.104 linespec.c --- linespec.c 13 Jul 2010 20:07:44 -0000 1.104 +++ linespec.c 1 Dec 2010 22:47:09 -0000 @@ -1589,15 +1589,20 @@ find_method (int funfirstline, char ***c if (strchr (saved_arg, '(') != NULL) { int i; + char *name = saved_arg; + char *canon = cp_canonicalize_string (name); + struct cleanup *cleanup; - for (i = 0; i < i1; ++i) + if (canon != NULL) { - char *name = saved_arg; - char *canon = cp_canonicalize_string (name); - - if (canon != NULL) - name = canon; + name = canon; + cleanup = make_cleanup (xfree, canon); + } + else + cleanup = make_cleanup (null_cleanup, NULL); + for (i = 0; i < i1; ++i) + { if (strcmp_iw (name, SYMBOL_LINKAGE_NAME (sym_arr[i])) == 0) { values.sals = (struct symtab_and_line *) @@ -1605,13 +1610,9 @@ find_method (int funfirstline, char ***c values.nelts = 1; values.sals[0] = find_function_start_sal (sym_arr[i], funfirstline); - if (canon) - xfree (canon); + do_cleanups (cleanup); return values; } - - if (canon) - xfree (canon); } error (_("the class `%s' does not have any method instance named %s\n"), --------------050806080405070303070809--