From 0fbb9c7baf13331d72fc42243cd031c2d7acdbe7 Mon Sep 17 00:00:00 2001 From: Lalatendu Mohanty Date: Thu, 2 Jan 2014 20:04:46 +0530 Subject: Crypt: Fixing incorrect placement of GF_FREE i.e. we are trying access the memory after freeing it using GF_FREE Change-Id: I2b22fd421131c618bd0d7c246ebf09f14751ad30 Signed-off-by: Lalatendu Mohanty Reviewed-on: http://review.gluster.org/6626 Reviewed-by: Xavier Hernandez Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/encryption/crypt/src/crypt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'xlators/encryption/crypt/src') diff --git a/xlators/encryption/crypt/src/crypt.c b/xlators/encryption/crypt/src/crypt.c index 47ff38e50..becff3e47 100644 --- a/xlators/encryption/crypt/src/crypt.c +++ b/xlators/encryption/crypt/src/crypt.c @@ -3277,15 +3277,15 @@ static int32_t linkop_grab_local(call_frame_t *frame, if (newloc) { local->newloc = GF_CALLOC(1, sizeof(*newloc), gf_crypt_mt_loc); if (!local->newloc) { - GF_FREE(local->loc); loc_wipe(local->loc); + GF_FREE(local->loc); goto error; } memset(local->newloc, 0, sizeof(*local->newloc)); ret = loc_copy(local->newloc, newloc); if (ret) { - GF_FREE(local->loc); loc_wipe(local->loc); + GF_FREE(local->loc); GF_FREE(local->newloc); goto error; } @@ -3297,19 +3297,21 @@ static int32_t linkop_grab_local(call_frame_t *frame, goto error; } return 0; - error: - if (local->xdata) - dict_unref(local->xdata); - if (local->fd) - fd_unref(local->fd); - local->fd = 0; - local->loc = NULL; - local->newloc = NULL; - local->op_ret = -1; - local->op_errno = ret; +error: + if (local) { + if (local->xdata) + dict_unref(local->xdata); + if (local->fd) + fd_unref(local->fd); + local->fd = 0; + local->loc = NULL; + local->newloc = NULL; + local->op_ret = -1; + local->op_errno = ret; + } - return ret; + return ret; } /* -- cgit