From 4a1d2ce2abb29207454e6ba1f714730642334dbd Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Fri, 16 Feb 1996 21:46:02 +0000 Subject: [PATCH] * dwarfread.c (free_utypes): New function. (read_file_scope): Call free_utypes as cleanup, rather than just freeing the utypes pointer. --- gdb/ChangeLog | 6 ++++++ gdb/dwarfread.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37fd73a093c..b2f631d7b8b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 16 10:02:34 1996 Fred Fish + + * dwarfread.c (free_utypes): New function. + (read_file_scope): Call free_utypes as cleanup, rather than just + freeing the utypes pointer. + Thu Feb 15 21:40:52 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * demangle.c (is_cplus_marker): New function, checks if a diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 3d034e1ea07..fb0234cd544 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -894,6 +894,33 @@ alloc_utype (die_ref, utypep) return (utypep); } +/* + +LOCAL FUNCTION + + free_utypes -- free the utypes array and reset pointer & count + +SYNOPSIS + + static void free_utypes (PTR dummy) + +DESCRIPTION + + Called via do_cleanups to free the utypes array, reset the pointer to NULL, + and set numutypes back to zero. This ensures that the utypes does not get + referenced after being freed. + */ + +static void +free_utypes (dummy) + PTR dummy; +{ + free (utypes); + utypes = NULL; + numutypes = 0; +} + + /* LOCAL FUNCTION @@ -1935,7 +1962,7 @@ read_file_scope (dip, thisdie, enddie, objfile) } numutypes = (enddie - thisdie) / 4; utypes = (struct type **) xmalloc (numutypes * sizeof (struct type *)); - back_to = make_cleanup (free, utypes); + back_to = make_cleanup (free_utypes, NULL); memset (utypes, 0, numutypes * sizeof (struct type *)); memset (ftypes, 0, FT_NUM_MEMBERS * sizeof (struct type *)); start_symtab (dip -> at_name, dip -> at_comp_dir, dip -> at_low_pc); @@ -1948,8 +1975,6 @@ read_file_scope (dip, thisdie, enddie, objfile) symtab -> language = cu_language; } do_cleanups (back_to); - utypes = NULL; - numutypes = 0; } /* -- 2.30.2