Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: fix crash-causing bug in copy_type_recursive
@ 2008-11-10 20:08 Tom Tromey
  2008-11-10 20:57 ` Daniel Jacobowitz
  2008-11-10 21:22 ` Pedro Alves
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2008-11-10 20:08 UTC (permalink / raw)
  To: gdb-patches

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) = 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-10 21:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-10 20:08 RFA: fix crash-causing bug in copy_type_recursive Tom Tromey
2008-11-10 20:57 ` Daniel Jacobowitz
2008-11-10 21:22 ` Pedro Alves
2008-11-10 21:26   ` Tom Tromey
2008-11-10 23:10     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox