This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: fix uninitialized field in Ada code


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]