[vlc-devel] [vlc-commits] directory: fix memory leaks
Tristan Matthews
le.businessman at gmail.com
Thu Sep 11 16:51:55 CEST 2014
On Thu, Sep 11, 2014 at 10:49 AM, Hannes Domani <git at videolan.org> wrote:
> 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);
>
Applied, thanks.
Best,
Tristan
More information about the vlc-devel
mailing list