From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29317 invoked by alias); 23 Oct 2012 21:22:05 -0000 Received: (qmail 29298 invoked by uid 22791); 23 Oct 2012 21:22:04 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS 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, 23 Oct 2012 21:21:59 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9NLLw3D022171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Oct 2012 17:21:59 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9NLLvQF027032 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Tue, 23 Oct 2012 17:21:58 -0400 Message-ID: <50870A74.80903@redhat.com> Date: Tue, 23 Oct 2012 21:22:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org ml" Subject: [RFA] Fix two memory leaks Content-Type: multipart/mixed; boundary="------------090608030405030106090107" 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: 2012-10/txt/msg00429.txt.bz2 This is a multi-part message in MIME format. --------------090608030405030106090107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 410 Hi, While testing some recent work, I noticed that valgrind was reporting two memory leaks related to linespec parsing/SaL resolution. The following patch fixes both leaks. Keith ChangeLog 2012-10-23 Keith Seitz * breakpoint.c (clear_command): Add cleanup for sals.sals if an argument is given. * linespec.c (parse_linespec): Do cleanups after parsing a convenience variable. --------------090608030405030106090107 Content-Type: text/x-patch; name="mem-leaks.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mem-leaks.patch" Content-length: 1281 diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8eeeacf..8b6b635 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -11788,6 +11788,7 @@ clear_command (char *arg, int from_tty) sals = decode_line_with_current_source (arg, (DECODE_LINE_FUNFIRSTLINE | DECODE_LINE_LIST_MODE)); + make_cleanup (xfree, sals.sals); default_match = 0; } else diff --git a/gdb/linespec.c b/gdb/linespec.c index 06634d2..e9918b1 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2095,20 +2095,17 @@ parse_linespec (linespec_parser *parser, char **argptr) cleanup = make_cleanup (xfree, var); PARSER_RESULT (parser)->line_offset = linespec_parse_variable (PARSER_STATE (parser), var); + do_cleanups (cleanup); /* If a line_offset wasn't found (VAR is the name of a user variable/function), then skip to normal symbol processing. */ if (PARSER_RESULT (parser)->line_offset.sign != LINE_OFFSET_UNKNOWN) { - discard_cleanups (cleanup); - /* Consume this token. */ linespec_lexer_consume_token (parser); goto convert_to_sals; } - - do_cleanups (cleanup); } else if (token.type != LSTOKEN_STRING && token.type != LSTOKEN_NUMBER) unexpected_linespec_error (parser); --------------090608030405030106090107--