[PATCH] augment-properties: fix a memory leak

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

 



On Thu, 2017-12-07 at 04:46 +0530, Arun Raghavan wrote:
> 
> 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.

I now noticed that this causes a compiler warning, because the first
pa_xfree(fn) call happens before variable declarations. I'll make
another version.

-- 
Tanu

https://www.patreon.com/tanuk


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

  Powered by Linux