mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
3b74824985
commit
1134de3c89
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user