fix cleanups in som_symtab_read
authorTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 16:28:29 +0000 (16:28 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 16:28:29 +0000 (16:28 +0000)
This fixes som_symtab_read not to leak cleanups.

* somread.c (som_symtab_read): Call do_cleanups.

gdb/ChangeLog
gdb/somread.c

index 86c63690db23855c651aff8a83d321e745fdba1f..2345ff8003a7f7de26ee36e898410a0d07c4f469 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+       * somread.c (som_symtab_read): Call do_cleanups.
+
 2013-05-30  Tom Tromey  <tromey@redhat.com>
 
        * printcmd.c (print_command_1): Unconditionally call do_cleanups.
index db6c4d441e9287632653f32130403e15f9e55935..6c6cc14c1177b67892b69a278b9697a4d5bf828e 100644 (file)
@@ -46,6 +46,7 @@ static void
 som_symtab_read (bfd *abfd, struct objfile *objfile,
                 struct section_offsets *section_offsets)
 {
+  struct cleanup *cleanup;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   unsigned int number_of_symbols;
   int val, dynamic;
@@ -65,7 +66,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
      We avoid using alloca because the memory size could be so large
      that we could hit the stack size limit.  */
   buf = xmalloc (symsize * number_of_symbols);
-  make_cleanup (xfree, buf);
+  cleanup = make_cleanup (xfree, buf);
   bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET);
   val = bfd_bread (buf, symsize * number_of_symbols, abfd);
   if (val != symsize * number_of_symbols)
@@ -316,6 +317,8 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
                                                                  section),
                                           objfile);
     }
+
+  do_cleanups (cleanup);
 }
 
 /* Scan and build partial symbols for a symbol file.