[PATCH v2] augment-properties: fix a memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 7 Dec 2017, at 04:56 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 | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/modules/module-augment-properties.c
> b/src/modules/module-augment-properties.c
> index f0584328d..3eb503aa0 100644
> --- a/src/modules/module-augment-properties.c
> +++ b/src/modules/module-augment-properties.c
> @@ -137,10 +137,13 @@ static char * find_desktop_file_in_dir(struct rule
> *r, const char *desktop_file_
>      pa_assert(st);
>  
>      fn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s.desktop",
>      desktop_file_dir, r->process_name);
> -    if (stat(fn, st) == 0) {
> +    if (stat(fn, st) == 0)
>          return fn;
> -    } else {
> +
> +    pa_xfree(fn);
> +
>  #ifdef DT_DIR
> +    {
>          DIR *desktopfiles_dir;
>          struct dirent *dir;
>  
> @@ -152,18 +155,20 @@ 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);
>          }
> -#endif
>      }
> +#endif
> +
>      return NULL;
>  }
>  
> -- 

Looks good.

-- Arun


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux