Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Hilfinger <hilfingr@gnat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one
Date: Tue, 13 Jan 2004 10:06:00 -0000	[thread overview]
Message-ID: <20040113100600.42C1FF2D70@nile.gnat.com> (raw)


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))


             reply	other threads:[~2004-01-13 10:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-13 10:06 Paul Hilfinger [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2004-01-09  8:22 [RFA] breakpoint.c: Avoid " Paul Hilfinger

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=20040113100600.42C1FF2D70@nile.gnat.com \
    --to=hilfingr@gnat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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