This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/hpux] hpread.c: init alloca'd memory, pr gdb/1661
- From: mec dot gnu at mindspring dot com (Michael Elizabeth Chastain)
- To: gdb-patches at sources dot redhat dot com, randolph at tausq dot org
- Date: Mon, 31 May 2004 16:12:02 -0400 (EDT)
- Subject: [patch/hpux] hpread.c: init alloca'd memory, pr gdb/1661
This patch fixes some uninitialized memory in the HP symbol
table reader. See PR symtab/1661.
I tested this on native hppa2.0w-hp-hpux11.11 with hpcc
B.11.11.28706.GP and hpacc A.03.45.
MAINTAINERS says that "Any [past] maintainer" can modify the hp/ux
symtab reader, so I'm going to commit this in 24 hours if nobody
objects. After that, I am also going to test it on gdb_6_1-branch
and commit it to gdb_6_1-branch.
Michael C
2004-05-31 Michael Chastain <mec.gnu@mindspring.com>
Fix PR symtab/1661.
* hpread.c (hpread_pxdb_needed): Call memset after alloca.
(hpread_read_struct_type): Likewise.
Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.48
diff -c -3 -p -r1.48 hpread.c
*** hpread.c 7 May 2004 05:48:49 -0000 1.48
--- hpread.c 31 May 2004 02:04:14 -0000
*************** hpread_pxdb_needed (bfd *sym_bfd)
*** 383,388 ****
--- 383,389 ----
if (header_section_size == (bfd_size_type) sizeof (DOC_info_PXDB_header))
{
buf = alloca (sizeof (DOC_info_PXDB_header));
+ memset (buf, 0, sizeof (DOC_info_PXDB_header));
if (!bfd_get_section_contents (sym_bfd,
header_section,
*************** hpread_pxdb_needed (bfd *sym_bfd)
*** 450,455 ****
--- 451,457 ----
{
buf = alloca (sizeof (PXDB_header));
+ memset (buf, 0, sizeof (PXDB_header));
if (!bfd_get_section_contents (sym_bfd,
header_section,
buf, 0,
*************** hpread_read_struct_type (dnttpointer hp_
*** 3686,3691 ****
--- 3688,3694 ----
/* Get space to record the next field/data-member. */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 3764,3769 ****
--- 3767,3773 ----
n_templ_args++;
/* Allocate and fill in a struct next_template */
t_new = (struct next_template *) alloca (sizeof (struct next_template));
+ memset (t_new, 0, sizeof (struct next_template));
t_new->next = t_list;
t_list = t_new;
t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name;
*************** hpread_read_struct_type (dnttpointer hp_
*** 3904,3909 ****
--- 3908,3914 ----
/* Get space to record this member function */
/* Note: alloca used; this will disappear on routine exit */
fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field));
+ memset (fn_new, 0, sizeof (struct next_fn_field));
fn_new->next = fn_list;
fn_list = fn_new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4021,4026 ****
--- 4026,4032 ----
/* Get space to record this static member */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4051,4056 ****
--- 4057,4063 ----
warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
/* Get space to record the next field/data-member. */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4082,4087 ****
--- 4089,4095 ----
warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
/* Get space to record the next field/data-member. */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4102,4107 ****
--- 4110,4116 ----
warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
/* Get space to record the next field/data-member. */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4150,4155 ****
--- 4159,4165 ----
/* Get space to record the next field/data-member. */
new = (struct nextfield *) alloca (sizeof (struct nextfield));
+ memset (new, 0, sizeof (struct nextfield));
new->next = list;
list = new;
*************** hpread_read_struct_type (dnttpointer hp_
*** 4233,4238 ****
--- 4243,4249 ----
break;
i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation));
+ memset (i_new, 0, sizeof (struct next_instantiation));
i_new->next = i_list;
i_list = i_new;
i_list->t = hpread_type_lookup (field, objfile);