Commit 06402f46 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

directory: fix double closedir()

parent 4a37004b
...@@ -203,14 +203,10 @@ static int directory_open (directory *p_dir, char *psz_entry, DIR **handle) ...@@ -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) static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
{ {
directory *p_dir; directory *p_dir = malloc (sizeof (*p_dir));
p_dir = malloc (sizeof (*p_dir));
if (unlikely (p_dir == NULL))
return NULL;
psz_uri = strdup (psz_uri); psz_uri = strdup (psz_uri);
if (unlikely (psz_uri == NULL)) if (unlikely (p_dir == NULL || psz_uri == NULL))
goto error; goto error;
p_dir->parent = p_sys->current; p_dir->parent = p_sys->current;
...@@ -236,11 +232,10 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri) ...@@ -236,11 +232,10 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
p_sys->current = p_dir; p_sys->current = p_dir;
return true; return true;
error: error:
closedir (handle); closedir (handle);
free (p_dir); free (p_dir);
free (psz_uri); free (psz_uri);
return false; return false;
} }
...@@ -307,7 +302,10 @@ int DirInit (access_t *p_access, DIR *handle) ...@@ -307,7 +302,10 @@ int DirInit (access_t *p_access, DIR *handle)
else else
uri = vlc_path2uri (p_access->psz_filepath, "file"); uri = vlc_path2uri (p_access->psz_filepath, "file");
if (unlikely (uri == NULL)) if (unlikely (uri == NULL))
{
closedir (handle);
goto error; goto error;
}
/* "Open" the base directory */ /* "Open" the base directory */
p_sys->current = NULL; p_sys->current = NULL;
...@@ -338,7 +336,6 @@ int DirInit (access_t *p_access, DIR *handle) ...@@ -338,7 +336,6 @@ int DirInit (access_t *p_access, DIR *handle)
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
closedir (handle);
free (p_sys); free (p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment