This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA: fix uninitialized field in Ada code
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 14 Dec 2011 15:29:56 -0500
- Subject: Re: RFA: fix uninitialized field in Ada code
- References: <m3fwgpdajr.fsf@fleche.redhat.com>
Hi Tom,
> The bug is that data->found_sym is not initialized by
> add_nonlocal_symbols.
> 2011-12-12 Tom Tromey <tromey@redhat.com>
>
> * ada-lang.c (add_nonlocal_symbols): Initialize data.found_sym.
Thanks for taking a look at this. The patch was good, but I decided
to make sure that the struct was always entirely initialized, so
I memset'ed it to zero.
Here is the patch I ended up checking in. Tested on x86_64-linux.
Thanks again,
--
Joel
commit c40e59292fbbec986e5d7c7714dba1d35fc104dd
Author: Joel Brobecker <brobecker@adacore.com>
Date: Wed Dec 14 14:39:44 2011 -0500
fix uninitialized field in ada-lang.c (struct match_data)
Field found_sym in add_nonlocal_symbols's struct match_data is
used uninitialized. Rather than adding the initialization of
this field (to zero), we set the entire structure to zero first,
and then set the fields that need to be initialized to non-zero
next.
gdb/ChangeLog:
* ada-lang.c (add_nonlocal_symbols): Initialize data to
all zeros. Remove setting of data.arg_sym to NULL.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 951e9fd..0cce947 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-14 Joel Brobecker <brobecker@adacore.com>
+ Tom Tromey <tromey@redhat.com>
+
+ * ada-lang.c (add_nonlocal_symbols): Initialize data to
+ all zeros. Remove setting of data.arg_sym to NULL.
+
2011-12-14 Pedro Alves <pedro@codesourcery.com>
PR threads/10729
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 30a561d..8f4292f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4923,8 +4923,8 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
struct objfile *objfile;
struct match_data data;
+ memset (&data, 0, sizeof data);
data.obstackp = obstackp;
- data.arg_sym = NULL;
ALL_OBJFILES (objfile)
{