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]

[patch] Fix crash in "info auto-load-scripts"


Hi.

I'm checking this into trunk and the 7.4 branch.

VEC_safe_push can realloc, which the current code doesn't handle.

2011-12-19  Doug Evans  <dje@google.com>

	* python/py-auto-load.c (info_auto_load_scripts): Pass address of
	scripts vector to collect_matching_scripts.
	(collect_matching_scripts): Update.

Index: python/py-auto-load.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-auto-load.c,v
retrieving revision 1.15
diff -u -p -r1.15 py-auto-load.c
--- python/py-auto-load.c	10 Dec 2011 22:51:47 -0000	1.15
+++ python/py-auto-load.c	20 Dec 2011 04:17:41 -0000
@@ -481,10 +481,10 @@ static int
 collect_matching_scripts (void **slot, void *info)
 {
   struct loaded_script *script = *slot;
-  VEC (loaded_script_ptr) *scripts = info;
+  VEC (loaded_script_ptr) **scripts_ptr = info;
 
   if (re_exec (script->name))
-    VEC_safe_push (loaded_script_ptr, scripts, script);
+    VEC_safe_push (loaded_script_ptr, *scripts_ptr, script);
 
   return 1;
 }
@@ -563,8 +563,9 @@ info_auto_load_scripts (char *pattern, i
   if (pspace_info != NULL && pspace_info->loaded_scripts != NULL)
     {
       immediate_quit++;
+      /* Pass a pointer to scripts as VEC_safe_push can realloc space.  */
       htab_traverse_noresize (pspace_info->loaded_scripts,
-			      collect_matching_scripts, scripts);
+			      collect_matching_scripts, &scripts);
       immediate_quit--;
     }
 


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