[vlc-commits] directory: fix memory leaks

Hannes Domani git at videolan.org
Thu Sep 11 16:49:08 CEST 2014


vlc | branch: master | Hannes Domani <ssbssa at yahoo.de> | Tue Sep  2 20:13:28 2014 +0200| [2fee22a9ece3a3ff0d60b2681adaeb628674a032] | committer: Tristan Matthews

directory: fix memory leaks

Signed-off-by: Tristan Matthews <le.businessman at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2fee22a9ece3a3ff0d60b2681adaeb628674a032
---

 modules/access/directory.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index cf9396c..5c471a2 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -220,18 +220,23 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
 #ifdef HAVE_OPENAT
     struct stat st;
     if (fstat (dirfd (handle), &st))
-        goto error;
+        goto error_filev;
     p_dir->device = st.st_dev;
     p_dir->inode = st.st_ino;
 #else
     p_dir->path = make_path (psz_uri);
     if (p_dir->path == NULL)
-        goto error;
+        goto error_filev;
 #endif
 
     p_sys->current = p_dir;
     return true;
 
+error_filev:
+    for (int i = 0; i < p_dir->filec; i++)
+        free (p_dir->filev[i]);
+    free (p_dir->filev);
+
 error:
     closedir (handle);
     free (p_dir);
@@ -249,6 +254,8 @@ static bool directory_pop (access_sys_t *p_sys)
     p_sys->current = p_old->parent;
     closedir (p_old->handle);
     free (p_old->uri);
+    for (int i = 0; i < p_old->filec; i++)
+        free (p_old->filev[i]);
     free (p_old->filev);
 #ifndef HAVE_OPENAT
     free (p_old->path);



More information about the vlc-commits mailing list