lib/path: fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8083862536
commit
91bf581742
|
@ -928,6 +928,7 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
|
|||
FILE *f;
|
||||
size_t setsize, len = maxcpus * 7;
|
||||
char buf[len];
|
||||
int rc;
|
||||
|
||||
*set = NULL;
|
||||
|
||||
|
@ -935,10 +936,12 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
|
|||
if (!f)
|
||||
return -errno;
|
||||
|
||||
if (!fgets(buf, len, f))
|
||||
return -errno;
|
||||
rc = fgets(buf, len, f) == NULL ? -errno : 0;
|
||||
fclose(f);
|
||||
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
len = strlen(buf);
|
||||
if (buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
|
|
Loading…
Reference in New Issue