[pulseaudio-discuss] [PATCH] augment-properties: fix a memory leak

Arun Raghavan arun at arunraghavan.net
Wed Dec 6 23:16:27 UTC 2017



On Thu, 7 Dec 2017, at 04:09 AM, Tanu Kaskinen wrote:
> If the desktop file is not found, fn was not being freed after the last
> loop iteration.
> 
> CID: 1462477
> ---
>  src/modules/module-augment-properties.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/modules/module-augment-properties.c
> b/src/modules/module-augment-properties.c
> index f0584328d..4c38e7418 100644
> --- a/src/modules/module-augment-properties.c
> +++ b/src/modules/module-augment-properties.c
> @@ -140,6 +140,7 @@ static char * find_desktop_file_in_dir(struct rule
> *r, const char *desktop_file_
>      if (stat(fn, st) == 0) {
>          return fn;
>      } else {
> +        pa_xfree(fn);
>  #ifdef DT_DIR
>          DIR *desktopfiles_dir;
>          struct dirent *dir;
> @@ -152,13 +153,14 @@ static char * find_desktop_file_in_dir(struct rule
> *r, const char *desktop_file_
>                      || pa_streq(dir->d_name, ".."))
>                      continue;
>  
> -                pa_xfree(fn);
>                  fn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s" PA_PATH_SEP
>                  "%s.desktop", desktop_file_dir, dir->d_name,
>                  r->process_name);
>  
>                  if (stat(fn, st) == 0) {
>                      closedir(desktopfiles_dir);
>                      return fn;
>                  }
> +
> +                pa_xfree(fn);
>              }
>              closedir(desktopfiles_dir);
>          }
> -- 

Looks good.

-- Arun


More information about the pulseaudio-discuss mailing list