[PATCH] augment-properties: fix a memory leak

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

 



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);
         }
-- 
2.14.2



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

  Powered by Linux