From 56a04936f29a21b7bd277b4b9dc92fea01730c2e Mon Sep 17 00:00:00 2001 From: Saravanakumar Arumugam Date: Wed, 25 Feb 2015 11:43:14 +0530 Subject: glusterd/snapshot: Fix memory leak while using scandir scandir allocates memory for dirent entries. Ensure to free them up once they are used. Noticed this while looking for a sample scandir implementation. Change-Id: Iff5f76e93e698d3f454f273d9dd7d9a15cf63953 BUG: 1196027 Signed-off-by: Saravanakumar Arumugam Reviewed-on: http://review.gluster.org/9739 Reviewed-by: Sachin Pandit Tested-by: Gluster Build System Reviewed-by: Rajesh Joseph Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index cdd19cd354d..476bfb8e017 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -551,6 +551,14 @@ glusterd_copy_geo_rep_session_files (char *session, } } out: + /* files are malloc'd by scandir, free them */ + if (file_count > 0) { + while (file_count--) { + free(files[file_count]); + } + free(files); + } + if (reg_exp) GF_FREE (reg_exp); -- cgit