summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorSaravanakumar Arumugam <sarumuga@redhat.com>2015-02-25 11:43:14 +0530
committerKaushal M <kaushal@redhat.com>2015-05-07 02:50:17 -0700
commitb6693de93a6f430bae4bfa9f4e58cf061664249b (patch)
tree7accf33f0424f5709e66e3e140a56ab12110592b /xlators
parent579186aeba940e3ec73093c48e17b5f6f94910d0 (diff)
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: 1218562 Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com> Reviewed-on: http://review.gluster.org/9739 Reviewed-by: Sachin Pandit <spandit@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: http://review.gluster.org/10559 Reviewed-by: Avra Sengupta <asengupt@redhat.com> Tested-by: NetBSD Build System
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index dbb9e934839..fec7494c341 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -567,6 +567,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);