* python/py-auto-load.c (info_auto_load_scripts): Pass address of
[deliverable/binutils-gdb.git] / gdb / python / py-auto-load.c
index 158b1cbfe227aef474e740be2c382e59f6a300ff..ef332ea8a1a15d25486592126680321d2bd7b543 100644 (file)
@@ -296,9 +296,6 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
       in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file,
                                        opened ? full_path : NULL);
 
-      if (opened)
-       free (full_path);
-
       if (! opened)
        {
          /* We don't throw an error, the program is still debuggable.  */
@@ -310,12 +307,15 @@ Use `info auto-load-scripts [REGEXP]' to list them."),
                       GDBPY_AUTO_SECTION_NAME, objfile->name);
              pspace_info->script_not_found_warning_printed = TRUE;
            }
-         continue;
        }
-
-      /* If this file is not currently loaded, load it.  */
-      if (! in_hash_table)
-       source_python_script_for_objfile (objfile, stream, file);
+      else
+       {
+         /* If this file is not currently loaded, load it.  */
+         if (! in_hash_table)
+           source_python_script_for_objfile (objfile, full_path);
+         fclose (stream);
+         xfree (full_path);
+       }
     }
 }
 
@@ -431,7 +431,7 @@ auto_load_objfile_script (struct objfile *objfile, const char *suffix)
         It's highly unlikely that we'd ever load it twice,
         and these scripts are required to be idempotent under multiple
         loads anyway.  */
-      source_python_script_for_objfile (objfile, input, debugfile);
+      source_python_script_for_objfile (objfile, debugfile);
       fclose (input);
     }
 
@@ -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, int from_tty)
   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--;
     }
 
This page took 0.026076 seconds and 4 git commands to generate.