Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA]: Fix do_cleanups if oldchain is NULL
Date: Wed, 17 Dec 2003 21:05:00 -0000	[thread overview]
Message-ID: <3FE0C502.7020408@redhat.com> (raw)

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

I recently solved a bug on the ia64 concerning cleanups.  What was 
happening was that a cleanup list was being re-initialized to NULL 
inside a loop and later do_cleanups() was called.  This caused the 
entire cleanup list to be run because the design is to run the list 
until the passed in cleanup is reached.  This caused other errors when 
the stream being used was deleted, etc...

This patch adds a check to do_my_cleanups() so no cleanups will be 
performed if the passed in chain is NULL.

Ok to commit?

-- Jeff J.

2003-12-17  Jeff Johnston  <jjohnstn@redhat.com>

        * utils.c (do_my_cleanups): Don't do cleanups if old chain
        passed in is NULL.



[-- Attachment #2: utils.patch --]
[-- Type: text/plain, Size: 794 bytes --]

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.110
diff -u -p -r1.110 utils.c
--- utils.c	21 Sep 2003 01:26:45 -0000	1.110
+++ utils.c	17 Dec 2003 20:35:56 -0000
@@ -316,11 +316,14 @@ do_my_cleanups (struct cleanup **pmy_cha
 		struct cleanup *old_chain)
 {
   struct cleanup *ptr;
-  while ((ptr = *pmy_chain) != old_chain)
+  if (old_chain != NULL)
     {
-      *pmy_chain = ptr->next;	/* Do this first incase recursion */
-      (*ptr->function) (ptr->arg);
-      xfree (ptr);
+      while ((ptr = *pmy_chain) != old_chain)
+        {
+          *pmy_chain = ptr->next;	/* Do this first incase recursion */
+          (*ptr->function) (ptr->arg);
+          xfree (ptr);
+        }
     }
 }
 

             reply	other threads:[~2003-12-17 21:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-17 21:05 Jeff Johnston [this message]
2004-01-02 16:07 ` Andrew Cagney
2004-01-02 17:51   ` Daniel Jacobowitz
2004-01-05 15:32     ` Andrew Cagney
2004-01-05 15:36       ` Daniel Jacobowitz
2004-01-05 18:59   ` J. Johnston
2004-01-05 19:06     ` Daniel Jacobowitz
2004-01-05 21:18       ` J. Johnston

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=3FE0C502.7020408@redhat.com \
    --to=jjohnstn@redhat.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