> From 9da6053e115e8abc07f8c877dde2d39af0c5101f Mon Sep 17 00:00:00 2001
> From: Vitezslav Crhonek <[email protected]>
> Date: Wed, 17 Mar 2021 11:30:43 +0100
> Subject: [PATCH 2/8] Fix memory leak
> 
> info_add_extension() returns new string based on 'dirname'. But that
> is the last usage of 'dirname' in the function.
> Free it to aviod memory leak at the end of the function (no matter
> which end it would be).
> ---
>  info/filesys.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/info/filesys.c b/info/filesys.c
> index c49088d66a..cfa06c0d77 100644
> --- a/info/filesys.c
> +++ b/info/filesys.c
> @@ -158,6 +158,7 @@ info_file_find_next_in_path (char *filename, int 
> *path_index, struct stat *finfo
>          }
>  
>        with_extension = info_add_extension (dirname, filename, finfo);
> +      free (dirname);
>  
>        if (with_extension)
>          {

There is a comment on infopath_next which says

  Return value should not be freed by caller.

I am going to remove the existing use of free in the calling function
(which was only used if there was a tilde in the directory name).


Reply via email to