From 33e9e8fcb98cd8ddd483b37ff7114ea9fd8d75fb Mon Sep 17 00:00:00 2001 From: Lalatendu Mohanty Date: Tue, 21 Jan 2014 02:27:03 +0530 Subject: quota: Fixing a possibility of GF_FREE on an array pointer Issue: when the charecter pointer is not heap allocated by the program we should not do GF_FREE on it. Change-Id: Ibccc25491a9ab924fd5b82c14566f551a061ec2e BUG: 789278 Signed-off-by: Lalatendu Mohanty Reviewed-on: http://review.gluster.org/6741 Reviewed-by: Raghavendra G Reviewed-by: Vijay Bellur Tested-by: Gluster Build System --- xlators/features/quota/src/quota.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'xlators/features/quota') diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 416d9ce652a..a8b4eb2c360 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -4027,6 +4027,7 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, char *path = NULL; int64_t cur_size = 0; quota_priv_t *priv = NULL; + gf_boolean_t dyn_mem = _gf_true; priv = this->private; if ((ctx->soft_lim <= 0) || (timerisset (&ctx->prev_log) && @@ -4041,6 +4042,7 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, if (!usage_str) { snprintf (size_str, sizeof (size_str), "%"PRId64, cur_size); usage_str = (char*) size_str; + dyn_mem = _gf_false; } inode_path (inode, NULL, &path); if (!path) @@ -4061,7 +4063,8 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, ctx->prev_log = cur_time; } - GF_FREE (usage_str); + if (dyn_mem) + GF_FREE (usage_str); } int32_t -- cgit