diff options
author | Zhang Huan <zhanghuan@open-fs.com> | 2018-07-23 15:27:41 +0800 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-07-28 07:21:12 +0000 |
commit | 75300258c42aeb29350ac55beb3360ca208454b5 (patch) | |
tree | 68fe2e6bc2b49e5049c9518ef11c9dc41fc84992 /api | |
parent | a6b5ec5cb5e2fb429b51c0d2b064fbd96c9de80c (diff) |
libgfapi: fix memory leak on old volume files
Fix missing free of fs->oldvolfile. This patch uses standard
calloc/realloc to allocate memory for vol file. As by the time fs struct
is destroyed, the THIS->ctx is already gone, that causes invalid memory
access.
Change-Id: I72ae19c76eb16e61f077714f7e52405fee721997
fixes: bz#1607689
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-mgmt.c | 4 | ||||
-rw-r--r-- | api/src/glfs.c | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 911a7330512..994f43c82f2 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -549,9 +549,9 @@ glusterfs_oldvolfile_update (struct glfs *fs, char *volfile, ssize_t size) fs->oldvollen = size; if (!fs->oldvolfile) { - fs->oldvolfile = GF_CALLOC (1, size+1, glfs_mt_volfile_t); + fs->oldvolfile = CALLOC (1, size+1); } else { - fs->oldvolfile = GF_REALLOC (fs->oldvolfile, size+1); + fs->oldvolfile = REALLOC (fs->oldvolfile, size+1); } if (!fs->oldvolfile) { diff --git a/api/src/glfs.c b/api/src/glfs.c index 6f7b6cde56d..a249534ffef 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -971,6 +971,9 @@ priv_glfs_free_from_ctx (struct glfs *fs) PTHREAD_MUTEX_DESTROY (&fs->upcall_list_mutex, fs->pthread_flags, GLFS_INIT_MUTEX_UPCALL); + if (fs->oldvolfile) + FREE (fs->oldvolfile); + FREE (fs->volname); FREE (fs); |