From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6055 invoked by alias); 13 Sep 2008 17:00:19 -0000 Received: (qmail 6038 invoked by uid 22791); 13 Sep 2008 17:00:17 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 13 Sep 2008 16:59:31 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m8DGwjcU022362 for ; Sat, 13 Sep 2008 12:59:05 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m8DGwXZ5013325 for ; Sat, 13 Sep 2008 12:58:34 -0400 Received: from opsy.redhat.com (vpn-10-2.bos.redhat.com [10.16.10.2]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m8DGwWmP022719; Sat, 13 Sep 2008 12:58:32 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 77D033785D1; Sat, 13 Sep 2008 10:58:39 -0600 (MDT) To: gdb-patches@sourceware.org Subject: RFA: fix minor memory leak in symfile.c From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Sat, 13 Sep 2008 17:00:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) 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: 2008-09/txt/msg00291.txt.bz2 I found a small memory leak while running valgrind on gdb. While auditing other callers of build_id_bfd_get, I found a use of 'free', so I fixed that as well. (Perhaps we ought to poison "free"?) Built & regtested on x86-64 (compile farm). I also verified the leak before- and after- on x86 F8. Please review. thanks, Tom :ADDPATCH symbols: 2008-09-13 Tom Tromey * symfile.c (build_id_verify): Free 'found'. (find_separate_debug_file): Use xfree, not free. diff --git a/gdb/symfile.c b/gdb/symfile.c index d067d2b..ed36497 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1235,6 +1235,9 @@ build_id_verify (const char *filename, struct build_id *check) if (!bfd_close (abfd)) warning (_("cannot close \"%s\": %s"), filename, bfd_errmsg (bfd_get_error ())); + + xfree (found); + return retval; } @@ -1363,7 +1366,7 @@ find_separate_debug_file (struct objfile *objfile) char *build_id_name; build_id_name = build_id_to_debug_filename (build_id); - free (build_id); + xfree (build_id); /* Prevent looping on a stripped .debug file. */ if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0) {