From 3c88948c9db0a5ae9ad0d551122a9e5efc036b0c Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 7 Mar 2010 14:04:35 +0300 Subject: [PATCH] Fixed memory leak in mc_closedir(). Signed-off-by: Andrew Borodin --- lib/vfs/mc-vfs/vfs.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/vfs/mc-vfs/vfs.c b/lib/vfs/mc-vfs/vfs.c index 639cf5b2f..4f71ce634 100644 --- a/lib/vfs/mc-vfs/vfs.c +++ b/lib/vfs/mc-vfs/vfs.c @@ -840,21 +840,23 @@ int mc_closedir (DIR *dirp) { int handle = *(int *) dirp; - struct vfs_class *vfs = vfs_op (handle); - int result; - struct vfs_dirinfo *dirinfo; + struct vfs_class *vfs; + int result = -1; - if (vfs == NULL) - return -1; + vfs = vfs_op (handle); + if (vfs != NULL) { + struct vfs_dirinfo *dirinfo; - dirinfo = vfs_info (handle); - if (dirinfo->converter != str_cnv_from_term) str_close_conv (dirinfo->converter); + dirinfo = vfs_info (handle); + if (dirinfo->converter != str_cnv_from_term) + str_close_conv (dirinfo->converter); - result = vfs->closedir ? (*vfs->closedir)(dirinfo->info) : -1; - vfs_free_handle (handle); - g_free (dirinfo); + result = vfs->closedir ? (*vfs->closedir)(dirinfo->info) : -1; + vfs_free_handle (handle); + g_free (dirinfo); + } g_free (dirp); - return result; + return result; } int mc_stat (const char *filename, struct stat *buf) {