Commit 2fee22a9 authored by ssbssa's avatar ssbssa Committed by Tristan Matthews
Browse files

directory: fix memory leaks

Signed-off-by: default avatarTristan Matthews <>
parent 6cccd64d
...@@ -220,18 +220,23 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri) ...@@ -220,18 +220,23 @@ static bool directory_push (access_sys_t *p_sys, DIR *handle, char *psz_uri)
struct stat st; struct stat st;
if (fstat (dirfd (handle), &st)) if (fstat (dirfd (handle), &st))
goto error; goto error_filev;
p_dir->device = st.st_dev; p_dir->device = st.st_dev;
p_dir->inode = st.st_ino; p_dir->inode = st.st_ino;
#else #else
p_dir->path = make_path (psz_uri); p_dir->path = make_path (psz_uri);
if (p_dir->path == NULL) if (p_dir->path == NULL)
goto error; goto error_filev;
#endif #endif
p_sys->current = p_dir; p_sys->current = p_dir;
return true; return true;
for (int i = 0; i < p_dir->filec; i++)
free (p_dir->filev[i]);
free (p_dir->filev);
error: error:
closedir (handle); closedir (handle);
free (p_dir); free (p_dir);
...@@ -249,6 +254,8 @@ static bool directory_pop (access_sys_t *p_sys) ...@@ -249,6 +254,8 @@ static bool directory_pop (access_sys_t *p_sys)
p_sys->current = p_old->parent; p_sys->current = p_old->parent;
closedir (p_old->handle); closedir (p_old->handle);
free (p_old->uri); free (p_old->uri);
for (int i = 0; i < p_old->filec; i++)
free (p_old->filev[i]);
free (p_old->filev); free (p_old->filev);
free (p_old->path); free (p_old->path);
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