From bc6087c57540bfdcde533bc90197b6553fb8003c Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 10 Feb 2021 13:21:22 +0100 Subject: [PATCH] Fix producer string memory leaks gcc/ChangeLog: * opts-common.c (decode_cmdline_option): Release werror_arg. * opts.c (gen_producer_string): Release output of gen_command_line_string. --- gcc/opts-common.c | 1 + gcc/opts.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 6cb5602896d..5e10edeb4cf 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -766,6 +766,7 @@ decode_cmdline_option (const char *const *argv, unsigned int lang_mask, werror_arg[0] = 'W'; size_t warning_index = find_opt (werror_arg, lang_mask); + free (werror_arg); if (warning_index != OPT_SPECIAL_unknown) { const struct cl_option *warning_option diff --git a/gcc/opts.c b/gcc/opts.c index fc5f61e13cc..24bb64198c8 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -3401,8 +3401,11 @@ char * gen_producer_string (const char *language_string, cl_decoded_option *options, unsigned int options_count) { - return concat (language_string, " ", version_string, " ", - gen_command_line_string (options, options_count), NULL); + char *cmdline = gen_command_line_string (options, options_count); + char *combined = concat (language_string, " ", version_string, " ", + cmdline, NULL); + free (cmdline); + return combined; } #if CHECKING_P -- 2.30.2