[systemd-devel] [PATCH] core: fix resource leak in manager_environment_add

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


On 09/16/2014 09:11 PM, Andreas Henriksson wrote:
> Second error path must free the (potentially) allocated memory in the
> first code chunk before returning.
> 
> Found by coverity. Fixes: CID#1237750
> ---
>  src/core/manager.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/core/manager.c b/src/core/manager.c
> index 0770727..e0c1cd1 100644
> --- a/src/core/manager.c
> +++ b/src/core/manager.c
> @@ -2751,8 +2751,10 @@ int manager_environment_add(Manager *m, char **minus, char **plus) {
>  
>          if (!strv_isempty(plus)) {
>                  b = strv_env_merge(2, l, plus);
> -                if (!b)
> +                if (!b) {
> +                        strv_free(a);
>                          return -ENOMEM;
> +                }
>  
>                  l = b;
>          }
> 

Applied, thanks!


More information about the systemd-devel mailing list