1
0
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:
Bryn M. Reeves 2015-08-10 10:08:03 +01:00
parent 3b74824985
commit 1134de3c89

View File

@ -79,11 +79,13 @@ static char *_program_id_from_proc(void)
if (!(comm = fopen(PROC_SELF_COMM, "r"))) if (!(comm = fopen(PROC_SELF_COMM, "r")))
return_NULL; return_NULL;
if (!fgets(buf, sizeof(buf), comm)) if (!fgets(buf, sizeof(buf), comm)) {
return_NULL; log_error("Could not read from %s", PROC_SELF_COMM);
fclose(comm);
return NULL;
}
if (fclose(comm)) fclose(comm);
return_NULL;
return dm_strdup(buf); return dm_strdup(buf);
} }