Fix producer string memory leaks
authorMartin Liska <mliska@suse.cz>
Wed, 10 Feb 2021 12:21:22 +0000 (13:21 +0100)
committerMartin Liska <mliska@suse.cz>
Fri, 12 Feb 2021 09:25:06 +0000 (10:25 +0100)
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
gcc/opts.c

index 6cb5602896d9ff7852178c1537534b1773e12e1f..5e10edeb4cfc9194d57bc5a7c29d8c7f921e90d5 100644 (file)
@@ -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
index fc5f61e13cce6d297a00ce4920a903aa0f039083..24bb64198c890ac11727be69af685949e10c781b 100644 (file)
@@ -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