[vlc-commits] directory: fix double closedir()

Rémi Denis-Courmont git at videolan.org
Mon Jul 7 18:09:44 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul  7 19:07:44 2014 +0300| [06402f46e312725d794a60ef7fc02ff24fbe1f0d] | committer: Rémi Denis-Courmont

directory: fix double closedir()

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

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

diff --git a/modules/access/directory.c b/modules/access/directory.c
index f4c6107..e95bb2d 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -203,14 +203,10 @@ static int directory_open (directory *p_dir, char *psz_entry, DIR **handle)
 
 static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
 {
-    directory *p_dir;
-
-    p_dir = malloc (sizeof (*p_dir));
-    if (unlikely (p_dir == NULL))
-        return NULL;
+    directory *p_dir = malloc (sizeof (*p_dir));
 
     psz_uri = strdup (psz_uri);
-    if (unlikely (psz_uri == NULL))
+    if (unlikely (p_dir == NULL || psz_uri == NULL))
         goto error;
 
     p_dir->parent = p_sys->current;
@@ -236,11 +232,10 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
     p_sys->current = p_dir;
     return true;
 
-    error:
+error:
     closedir (handle);
     free (p_dir);
     free (psz_uri);
-
     return false;
 }
 
@@ -307,7 +302,10 @@ int DirInit (access_t *p_access, DIR *handle)
     else
         uri = vlc_path2uri (p_access->psz_filepath, "file");
     if (unlikely (uri == NULL))
+    {
+        closedir (handle);
         goto error;
+    }
 
     /* "Open" the base directory */
     p_sys->current = NULL;
@@ -338,7 +336,6 @@ int DirInit (access_t *p_access, DIR *handle)
     return VLC_SUCCESS;
 
 error:
-    closedir (handle);
     free (p_sys);
     return VLC_EGENERIC;
 }



More information about the vlc-commits mailing list