This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one
- From: Andrew Cagney <cagney at gnu dot org>
- To: Paul Hilfinger <hilfingr at gnat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Tue, 27 Jan 2004 20:40:50 -0500
- Subject: Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one
- References: <20040113100600.42C1FF2D70@nile.gnat.com> <40171150.5080708@gnu.org>
Anyway, I've committed the attached (slightly tweaked).
Doh! Try ...
2004-01-27 Paul N. Hilfinger <hilfinger@gnat.com>
* breakpoint.c (breakpoint_re_set_one): Set b->cond, b->val, and
b->exp to NULL after freeing so that error during re-parsing or
evaluation of expressions associated with breakpoint don't
eventually lead to re-freeing of storage.
Committed by Andrew Cagney.
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.151
diff -u -r1.151 breakpoint.c
--- breakpoint.c 27 Jan 2004 03:13:34 -0000 1.151
+++ breakpoint.c 28 Jan 2004 01:34:34 -0000
@@ -6970,12 +6970,22 @@
/* So for now, just use a global context. */
if (b->exp)
- xfree (b->exp);
+ {
+ xfree (b->exp);
+ /* Avoid re-freeing b->exp if an error during the call to
+ parse_expression. */
+ b->exp = NULL;
+ }
b->exp = parse_expression (b->exp_string);
b->exp_valid_block = innermost_block;
mark = value_mark ();
if (b->val)
- value_free (b->val);
+ {
+ value_free (b->val);
+ /* Avoid re-freeing b->val if an error during the call to
+ evaluate_expression. */
+ b->val = NULL;
+ }
b->val = evaluate_expression (b->exp);
release_value (b->val);
if (VALUE_LAZY (b->val) && breakpoint_enabled (b))
@@ -6985,7 +6995,12 @@
{
s = b->cond_string;
if (b->cond)
- xfree (b->cond);
+ {
+ xfree (b->cond);
+ /* Avoid re-freeing b->exp if an error during the call
+ to parse_exp_1. */
+ b->cond = NULL;
+ }
b->cond = parse_exp_1 (&s, (struct block *) 0, 0);
}
if (breakpoint_enabled (b))