fix cleanup handling in macho_symfile_read
authorTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 17:06:31 +0000 (17:06 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 17:06:31 +0000 (17:06 +0000)
macho_symfile_read leaks a cleanup by assigning to 'back_to' too late.

* machoread.c (macho_symfile_read): Assign first cleanup to
'back_to'.

gdb/ChangeLog
gdb/machoread.c

index fc3829ade6f5043244f2d5a56f5d8a260dae747f..56be9230954c4b24ae585d80b72ab0b641cadcc8 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+       * machoread.c (macho_symfile_read): Assign first cleanup to
+       'back_to'.
+
 2013-05-30  Tom Tromey  <tromey@redhat.com>
 
        * m32r-rom.c (m32r_load): Call do_cleanups at all returns.
index 9877f07b4d343df6aad6c30bd9b2639be3797108..d294960f63d294eb0b74cb78ff0f6ade150ba8c0 100644 (file)
@@ -871,10 +871,10 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
           struct cleanup *back_to;
 
          symbol_table = (asymbol **) xmalloc (storage_needed);
-         make_cleanup (xfree, symbol_table);
+         back_to = make_cleanup (xfree, symbol_table);
 
           init_minimal_symbol_collection ();
-          back_to = make_cleanup_discard_minimal_symbols ();
+          make_cleanup_discard_minimal_symbols ();
 
          symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);