diff options
author | Raghavendra G <raghavendra@gluster.com> | 2011-08-23 12:32:36 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-08-24 01:17:07 -0700 |
commit | 6f1062f3473407cebfd5d902db2d2c6965dcf034 (patch) | |
tree | 55266b389d081bcc3f3d106b5fdf25f547579d20 /xlators/performance | |
parent | f65668427467f07f1b7026498f739254967f5bef (diff) |
performance/stat-prefetch: fix memory leak
BUG: 3467
Change-Id: I9b7e2cc5ed824544a8c6549bf99f9e013fd70e56
Reviewed-on: http://review.gluster.com/309
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index c0f432f7c..5f4a32924 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -928,7 +928,7 @@ int32_t sp_get_ancestors (char *path, char **parent, char **grand_parent) { int32_t ret = -1, i = 0; - char *cpy = NULL; + char *cpy = NULL, *tmp = NULL; if (!path || !parent || !grand_parent) { ret = 0; @@ -940,7 +940,14 @@ sp_get_ancestors (char *path, char **parent, char **grand_parent) break; } + tmp = cpy; + cpy = gf_strdup (path); + + if (tmp != NULL) { + GF_FREE (tmp); + } + if (cpy == NULL) { ret = -errno; goto out; @@ -950,16 +957,20 @@ sp_get_ancestors (char *path, char **parent, char **grand_parent) switch (i) { case 0: - *parent = path; + *parent = gf_strdup (path); break; case 1: - *grand_parent = path; + *grand_parent = gf_strdup (path); break; } } ret = 0; out: + if (cpy != NULL) { + GF_FREE (cpy); + } + return ret; } |