[systemd-devel] [PATCH] shared: fix resource leak in config_parse_default_instance

Daniel Mack daniel at zonque.org
Tue Sep 16 12:52:57 PDT 2014


On 09/16/2014 09:36 PM, Andreas Henriksson wrote:
> The recently allocated "printed" is not freed on error path.
> 
> Found by coverity. Fixes: CID#1237745
> ---
>  src/shared/install.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/install.c b/src/shared/install.c
> index 5d3fcf5..61e572b 100644
> --- a/src/shared/install.c
> +++ b/src/shared/install.c
> @@ -1025,8 +1025,10 @@ static int config_parse_default_instance(
>          if (r < 0)
>                  return r;
>  
> -        if (!unit_instance_is_valid(printed))
> +        if (!unit_instance_is_valid(printed)) {
> +                free(printed);
>                  return -EINVAL;
> +        }
>  
>          free(i->default_instance);
>          i->default_instance = printed;
> 

Applied, thanks!


More information about the systemd-devel mailing list