[PATCH] libgccjit: Fix several memory leaks in the driver

Joseph Myers joseph@codesourcery.com
Thu Aug 20 22:26:20 GMT 2020


On Thu, 9 Jul 2020, Alex Coplan wrote:

> 2020-07-09  Alex Coplan  <alex.coplan@arm.com>
> 
> 	* gcc.c (set_static_spec): New.
> 	(set_static_spec_owned): New.
> 	(set_static_spec_shared): New.
> 	(driver::maybe_putenv_COLLECT_LTO_WRAPPER): Use
> 	set_static_spec_owned() to take ownership of lto_wrapper_file
> 	such that it gets freed in driver::finalize.
> 	(driver::maybe_run_linker): Use set_static_spec_shared() to
> 	ensure that we don't try and free() the static string "ld",
> 	also ensuring that any previously-allocated string in
> 	linker_name_spec is freed. Likewise with argv0.
> 	(driver::finalize): Use set_static_spec_shared() when resetting
> 	specs that previously had allocated strings; remove if(0)
> 	around call to free().

OK with a comment added to set_static_spec, documenting the semantics of 
the function and its arguments.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Gcc-patches mailing list