diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-08-10 10:08:03 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-08-10 20:20:26 +0100 |
commit | 1134de3c89c5a07699365031d0cb88383e365929 (patch) | |
tree | a2a61759d3ac6e710b107d8fcf20e05a07136043 | |
parent | 3b74824985f7e4e90f0ba9668724abd08d5fef74 (diff) | |
download | lvm2-1134de3c89c5a07699365031d0cb88383e365929.tar.gz |
libdm: fix FILE leak in _program_id_from_proc() (Coverity)
Make sure comm is closed in the error path of _program_id_from_proc().
libdm/libdm-stats.c: 98 in dm_stats_create() - Variable "comm" going out of scope leaks the storage it points to.
-rw-r--r-- | libdm/libdm-stats.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index bf3cad0e0..64ca23f57 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -79,11 +79,13 @@ static char *_program_id_from_proc(void) if (!(comm = fopen(PROC_SELF_COMM, "r"))) return_NULL; - if (!fgets(buf, sizeof(buf), comm)) - return_NULL; + if (!fgets(buf, sizeof(buf), comm)) { + log_error("Could not read from %s", PROC_SELF_COMM); + fclose(comm); + return NULL; + } - if (fclose(comm)) - return_NULL; + fclose(comm); return dm_strdup(buf); } |