This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA]: Fix do_cleanups if oldchain is NULL


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.


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);
+        }
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]