summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/store.c
diff options
context:
space:
mode:
authornik-redhat <nladha@redhat.com>2020-08-11 23:12:26 +0530
committerMOHIT AGRAWAL <moagrawa@redhat.com>2020-08-18 04:18:21 +0000
commitf5f94e574a8e27e4a6665567db30b82618115694 (patch)
treef596d4356eb0d05741d29de5789a9b38ca509d72 /libglusterfs/src/store.c
parentb86d95dfa3ba8f08dc2ef8c6e6b0dcd5ea4314b7 (diff)
glusterd: memory deallocated twice
Issue: If the the pointer tmptier is destroyed in the function code it still it checks for the same in the out label. And tries to destroy the same pointer again. Fix: So, instead of passing the ptr by value, if we pass it by reference then, on making the ptr in the function the value will persist, in the calling function and next time when the gf_store_iter_destory() is called it won't try to free the ptr again. CID: 1430122 Updates: #1060 Change-Id: I019cea8e301c7cc87be792c03b58722fc96f04ef Signed-off-by: nik-redhat <nladha@redhat.com>
Diffstat (limited to 'libglusterfs/src/store.c')
-rw-r--r--libglusterfs/src/store.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 74cf5459c3c..5c316b9291a 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -649,24 +649,24 @@ out:
}
int32_t
-gf_store_iter_destroy(gf_store_iter_t *iter)
+gf_store_iter_destroy(gf_store_iter_t **iter)
{
int32_t ret = -1;
- if (!iter)
+ if (!(*iter))
return 0;
/* gf_store_iter_new will not return a valid iter object with iter->file
* being NULL*/
- ret = fclose(iter->file);
+ ret = fclose((*iter)->file);
if (ret)
gf_msg("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
"Unable"
" to close file: %s, ret: %d",
- iter->filepath, ret);
+ (*iter)->filepath, ret);
- GF_FREE(iter);
- iter = NULL;
+ GF_FREE(*iter);
+ *iter = NULL;
return ret;
}