From: Keith Seitz <keiths@redhat.com>
To: "gdb-patches@sourceware.org ml" <gdb-patches@sourceware.org>
Subject: [RFA] Fix two memory leaks
Date: Tue, 23 Oct 2012 21:22:00 -0000 [thread overview]
Message-ID: <50870A74.80903@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
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 <keiths@redhat.com>
* 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.
[-- Attachment #2: mem-leaks.patch --]
[-- Type: text/x-patch, Size: 1281 bytes --]
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);
next reply other threads:[~2012-10-23 21:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-23 21:22 Keith Seitz [this message]
2012-10-23 22:02 ` Joel Brobecker
2012-10-24 14:55 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50870A74.80903@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox