Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one
@ 2004-01-13 10:06 Paul Hilfinger
  2004-01-28  1:36 ` Andrew Cagney
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Hilfinger @ 2004-01-13 10:06 UTC (permalink / raw)
  To: gdb-patches


Here is a follow-up on my earlier patch.  I found a couple of other 
instances of potential double freeing in the same routine.

OK?

Paul Hilfinger

2004-01-12  Paul N. Hilfinger  <hilfinger@gnat.com>

	* breakpoint.c: Update copyright to include 2004.
	(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.
	
Index: current-public.41/gdb/breakpoint.c
--- current-public.41/gdb/breakpoint.c Sun, 04 Jan 2004 17:51:24 -0800 hilfingr (GdbPub/g/23_breakpoint 1.1.1.7.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 644)
+++ current-public.41(w)/gdb/breakpoint.c Tue, 13 Jan 2004 01:17:24 -0800 hilfingr (GdbPub/g/23_breakpoint 1.1.1.7.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 644)
@@ -1,8 +1,8 @@
 /* Everything about breakpoints, for GDB.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
-   Foundation, Inc.
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -7009,6 +7009,8 @@ breakpoint_re_set_one (void *bint)
 	      s = b->cond_string;
 	      if (b->cond)
 		xfree (b->cond);
+	      /* Avoid re-freeing b->cond if error during parse_exp_1. */
+	      b->cond = NULL;
 	      b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
 	    }
 
@@ -7077,11 +7079,15 @@ breakpoint_re_set_one (void *bint)
       /* So for now, just use a global context.  */
       if (b->exp)
 	xfree (b->exp);
+      /* Avoid re-freeing b->exp if error during 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);
+      /* Avoid re-freeing b->val if error during evaluate_expression. */
+      b->val = NULL;
       b->val = evaluate_expression (b->exp);
       release_value (b->val);
       if (VALUE_LAZY (b->val) && breakpoint_enabled (b))
@@ -7092,6 +7098,8 @@ breakpoint_re_set_one (void *bint)
 	  s = b->cond_string;
 	  if (b->cond)
 	    xfree (b->cond);
+	  /* Avoid re-freeing b->cond if error during parse_exp_1. */
+	  b->cond = NULL;
 	  b->cond = parse_exp_1 (&s, (struct block *) 0, 0);
 	}
       if (breakpoint_enabled (b))


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-01-29 14:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-13 10:06 [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one Paul Hilfinger
2004-01-28  1:36 ` Andrew Cagney
2004-01-28  1:44   ` Andrew Cagney
2004-01-28 12:30     ` Paul Hilfinger
2004-01-28 20:33       ` Andrew Cagney
2004-01-28 21:42         ` Paul Hilfinger
2004-01-29 11:16         ` [PATCH] Test for " Paul Hilfinger
2004-01-29 14:06           ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox