Fix crash in machoread.c
[deliverable/binutils-gdb.git] / gdb / machoread.c
index 4c1d4f0bfa78ee689fcc85a9815eba554b713ad5..07e1cdaf4f8aaac1ce2505eb1adc99d7b144db8e 100644 (file)
@@ -793,6 +793,9 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   bfd *abfd = objfile->obfd;
   long storage_needed;
   std::vector<oso_el> oso_vector;
+  /* We have to hold on to the symbol table until the call to
+     macho_symfile_read_all_oso at the end of this function.  */
+  gdb::def_vector<asymbol *> symbol_table;
 
   /* Get symbols from the symbol table only if the file is an executable.
      The symbol table of object files is not relocated and is expected to
@@ -812,8 +815,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
        {
          long symcount;
 
-         gdb::def_vector<asymbol *> symbol_table (storage_needed
-                                                  / sizeof (asymbol *));
+         symbol_table.resize (storage_needed / sizeof (asymbol *));
 
           minimal_symbol_reader reader (objfile);
 
This page took 0.025613 seconds and 4 git commands to generate.