This is the mail archive of the gdb-patches@sourceware.org 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]

[gdbserver] Make it safe for the callback function to delete the currently iterated inferior.


I've been carrying this for non-stop + multiprocess changes, but
since this is a common idiom in GDB, I'm checking it in separately
as obvious.

-- 
Pedro Alves

2009-03-22  Pedro Alves  <pedro@codesourcery.com>

	* inferiors.c (find_inferior): Make it safe for the callback
	function to delete the currently iterated inferior.

---
 gdb/gdbserver/inferiors.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: src/gdb/gdbserver/inferiors.c
===================================================================
--- src.orig/gdb/gdbserver/inferiors.c	2009-03-22 22:26:44.000000000 +0000
+++ src/gdb/gdbserver/inferiors.c	2009-03-22 22:26:51.000000000 +0000
@@ -180,9 +180,12 @@ find_inferior (struct inferior_list *lis
 
   while (inf != NULL)
     {
+      struct inferior_list_entry *next;
+
+      next = inf->next;
       if ((*func) (inf, arg))
 	return inf;
-      inf = inf->next;
+      inf = next;
     }
 
   return NULL;


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