summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorMichael Scherer <misc@redhat.com>2017-02-24 22:32:06 +0100
committerNiels de Vos <ndevos@redhat.com>2017-05-29 10:54:57 +0000
commitff1a1694112f141991e24284b90f568506aaca41 (patch)
treeb9463fbf924c2190ff0a42dcb34d6490676bfdc3 /xlators
parentde3368a53d9b2d8e035fe070c011a1b78d34559a (diff)
nfs/netgroups: do not free the same file twice
Coverity warn about a code path where 'file' is freed twice. And reading the code, I also found that 'line' shouldn't be freed using GF_FREE since it was allocated by getline. Also call _ng_deinit_parsers() in the success case, preventing leaking two 'struct parser' upon multiple calls to ng_file_parse(). Change-Id: I05d71fdbf3b48a25d35e7a56a4c245ceb2dd6ed9 BUG: 789278 Signed-off-by: Michael Scherer <misc@redhat.com> [ndevos: add _ng_deinit_parsers() cleanup suggested by Nithya] Reviewed-on: https://review.gluster.org/16759 Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/nfs/server/src/netgroups.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/xlators/nfs/server/src/netgroups.c b/xlators/nfs/server/src/netgroups.c
index 8af9cb39f31..01b50092a6d 100644
--- a/xlators/nfs/server/src/netgroups.c
+++ b/xlators/nfs/server/src/netgroups.c
@@ -1131,8 +1131,6 @@ ng_file_parse (const char *filepath)
gf_msg (GF_NG, GF_LOG_CRITICAL, ENOMEM,
NFS_MSG_NO_MEMORY, "Allocation error "
"while parsing line!");
- ng_file_deinit (file);
- GF_FREE (line);
goto err;
}
if (ret != 0) {
@@ -1148,9 +1146,14 @@ ng_file_parse (const char *filepath)
if (fp)
fclose(fp);
+ _ng_deinit_parsers ();
+
return file;
err:
+ if (line)
+ free(line);
+
if (file)
ng_file_deinit (file);