[PATCH 06/10] xfree86: loader: fix memory leaks in LoaderListDirs
Peter Hutterer
peter.hutterer at who-t.net
Tue Mar 29 14:25:56 PDT 2011
On Tue, Mar 29, 2011 at 06:12:32PM +0300, Tiago Vignatti wrote:
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
> hw/xfree86/loader/loadmod.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
> index eaa99e8..f304d0a 100644
> --- a/hw/xfree86/loader/loadmod.c
> +++ b/hw/xfree86/loader/loadmod.c
> @@ -532,6 +532,7 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
> FreePathList(pathlist);
> FreeSubdirs(subdirs);
> FreePatterns(patterns);
> + closedir(d);
> return NULL;
> }
> listing[n] = malloc(len + 1);
> @@ -540,6 +541,7 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
> FreePathList(pathlist);
> FreeSubdirs(subdirs);
> FreePatterns(patterns);
> + closedir(d);
> return NULL;
> }
> strncpy(listing[n], dp->d_name + match[1].rm_so,
> @@ -556,6 +558,9 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
> }
> if (listing)
> listing[n] = NULL;
> +
> + FreeSubdirs(subdirs);
> + FreePatterns(patterns);
> return listing;
> }
>
> --
> 1.7.0.4
this seems like it could be better solved with a single exit path. maybe a
follow-up patch?
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Cheers,
Peter
More information about the xorg-devel
mailing list