From 0ef443cf01de9153f66d9327784c6137d387dade Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 19 Nov 2014 19:08:29 +0000 Subject: [PATCH] PR jit/63854: Fix memory leak within gcc_options gcc/ChangeLog: PR jit/63854 * opts.c (finalize_options_struct): New. * opts.h (finalize_options_struct): New. * toplev.c (toplev::finalize): Call finalize_options_struct on global_options and global_options_set. From-SVN: r217791 --- gcc/ChangeLog | 8 ++++++++ gcc/opts.c | 8 ++++++++ gcc/opts.h | 1 + gcc/toplev.c | 3 +++ 4 files changed, 20 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15010a091a8..90e86f6de00 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-11-19 David Malcolm + + PR jit/63854 + * opts.c (finalize_options_struct): New. + * opts.h (finalize_options_struct): New. + * toplev.c (toplev::finalize): Call finalize_options_struct + on global_options and global_options_set. + 2014-11-19 Manuel López-Ibáñez Jakub Jelinek diff --git a/gcc/opts.c b/gcc/opts.c index a83345b91e2..f3deb4046a8 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -307,6 +307,14 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) targetm_common.option_init_struct (opts); } +/* Release any allocations owned by OPTS. */ + +void +finalize_options_struct (struct gcc_options *opts) +{ + XDELETEVEC (opts->x_param_values); +} + /* If indicated by the optimization level LEVEL (-Os if SIZE is set, -Ofast if FAST is set, -Og if DEBUG is set), apply the option DEFAULT_OPT to OPTS and OPTS_SET, diagnostic context DC, location LOC, with language diff --git a/gcc/opts.h b/gcc/opts.h index f6940823403..c3ec94241fb 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -325,6 +325,7 @@ extern void decode_cmdline_options_to_array (unsigned int argc, extern void init_options_once (void); extern void init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set); +extern void finalize_options_struct (struct gcc_options *opts); extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, diff --git a/gcc/toplev.c b/gcc/toplev.c index 86c4b81b3ae..6021807834c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2170,4 +2170,7 @@ toplev::finalize (void) ipa_cp_c_finalize (); ipa_reference_c_finalize (); params_c_finalize (); + + finalize_options_struct (&global_options); + finalize_options_struct (&global_options_set); } -- 2.30.2