Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: Paul Hilfinger <hilfingr@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] breakpoint.c: Avoid double freeing in breakpoint_re_set_one
Date: Wed, 28 Jan 2004 01:44:00 -0000	[thread overview]
Message-ID: <40171322.7080704@gnu.org> (raw)
In-Reply-To: <40171150.5080708@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 72 bytes --]

> Anyway, I've committed the attached (slightly tweaked).

Doh! Try ...

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1649 bytes --]

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

  reply	other threads:[~2004-01-28  1:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-13 10:06 Paul Hilfinger
2004-01-28  1:36 ` Andrew Cagney
2004-01-28  1:44   ` Andrew Cagney [this message]
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=40171322.7080704@gnu.org \
    --to=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=hilfingr@gnat.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