From af8c670de35fc8cacf0357b96ef411638a7ac778 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 6 Apr 2018 13:58:39 -0400 Subject: [PATCH] Fix memory leak in vfswrap_getwd() Signed-off-by: Andrew Walker --- source3/modules/vfs_default.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a26bec457ae..d0614e8b3ff 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2215,24 +2215,16 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle, TALLOC_CTX *ctx) { char *result; - struct smb_filename *smb_fname = NULL; + struct smb_filename *result_fname = NULL; START_PROFILE(syscall_getwd); result = sys_getwd(); END_PROFILE(syscall_getwd); - - if (result == NULL) { - return NULL; - } - smb_fname = synthetic_smb_fname(ctx, - result, - NULL, - NULL, - 0); - if (smb_fname == NULL) { + if (result) { + result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0); SAFE_FREE(result); } - return smb_fname; + return result_fname; } /********************************************************************* -- 2.15.1 (Apple Git-101)