kgdb: Fix double-free bug
authorJohn Marino <dragonflybsd@marino.st>
Sun, 1 Jan 2012 12:00:29 +0000 (13:00 +0100)
committerCharlie Root <root@akane.zefyris.com>
Sun, 1 Jan 2012 13:49:19 +0000 (14:49 +0100)
It was a mistake to reuse target sections for each inferior.  Leaving the
default section for each program space eliminates the redundant xfrees.
The exec.c function "resize_table_sections" code was painful to look at with
unused variables and unnecessary memory reallocations, so it was altered
at the same time.

contrib/gdb-7/README.DRAGONFLY
contrib/gdb-7/gdb/exec.c
gnu/usr.bin/gdb/kgdb/trgt.c

index d917708..f4fc372 100644 (file)
@@ -24,6 +24,7 @@ Local modifications applied to following files:
        gdb/configure.tgt
        gdb/corelow.c
        gdb/defs.h
+       gdb/exec.c
        gdb/i386-tdep.h
        gdb/i386bsd-nat.c
        gdb/i386fbsd-tdep.c
index a2da9d5..4cb275a 100644 (file)
@@ -400,13 +400,14 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect,
 int
 resize_section_table (struct target_section_table *table, int num_added)
 {
-  struct target_section *old_value;
   int old_count;
   int new_count;
 
-  old_value = table->sections;
   old_count = table->sections_end - table->sections;
 
+  if (!num_added)
+    return old_count;
+
   new_count = num_added + old_count;
 
   if (new_count)
index d9516d3..61c424b 100644 (file)
@@ -143,8 +143,6 @@ kgdb_trgt_open(char *filename, int from_tty)
                        pspace = add_program_space(new_address_space());
                        pspace->symfile_object_file = symfile_objfile;
                        pspace->objfiles = object_files;
-                       pspace->target_sections = 
-                               current_program_space->target_sections;
                      }
                      inf8->pspace = pspace;
                      inf8->aspace = pspace->aspace;