From 0c0e1d564f5a0f834169af6171d609a786cb3792 Mon Sep 17 00:00:00 2001 From: vmallika Date: Fri, 3 Jul 2015 15:16:57 +0530 Subject: posix: fix mem-leak in posix_get_ancestry error path This is a backport of http://review.gluster.org/#/c/11522/ > Change-Id: I47c8a8f170151f6374fc0420278aedf3ff5443ee > BUG: 1207735 > Signed-off-by: vmallika Change-Id: I7863634ba7b3a2e8933d891df72cda7e129aa2a2 BUG: 1229282 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/11528 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- xlators/storage/posix/src/posix.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 19f537cf29c..46c69e6898f 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3603,6 +3603,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + strlen (temppath) + 1 ); if (!tempv) { GF_FREE (*path); + *path = NULL; op_ret = -1; *op_errno = ENOMEM; goto out; @@ -3617,6 +3618,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, count--; } + op_ret = 0; out: if (dirp) { op_ret = closedir (dirp); @@ -3807,6 +3809,11 @@ posix_get_ancestry (xlator_t *this, inode_t *leaf_inode, } out: + if (ret && path && *path) { + GF_FREE (*path); + *path = NULL; + } + return ret; } -- cgit