This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFA: fix crash-causing bug in copy_type_recursive
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 10 Nov 2008 12:40:01 -0700
- Subject: RFA: fix crash-causing bug in copy_type_recursive
- Reply-to: Tom Tromey <tromey at redhat dot com>
On the Python branch I ran into a crash that was caused by
copy_type_recursive not clearing the memory for new fields. This was
probably introduced when I changed all the type flags back in August,
but I didn't research to see for sure.
The fix is to clear the newly allocated memory.
Every other places that allocates new fields does this.
I do not have a test failing case for trunk.
Built and regtested on x86-64 (compile farm).
Ok? (I almost checked this in as obvious...)
Tom
2008-11-10 Tom Tromey <tromey@redhat.com>
* gdbtypes.c (copy_type_recursive): Clear new fields.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b5a5de0..5b9d0e8 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2977,6 +2977,7 @@ copy_type_recursive (struct objfile *objfile,
nfields = TYPE_NFIELDS (type);
TYPE_FIELDS (new_type) = xmalloc (sizeof (struct field) * nfields);
+ memset (TYPE_FIELDS (new_type), 0, sizeof (struct field) * nfields);
for (i = 0; i < nfields; i++)
{
TYPE_FIELD_ARTIFICIAL (new_type, i) =