mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
tools: Fix memory leak
Coverity found that commit id 'c661b675f' needed to create a cleanup path to handle the closing of 'fp' if the virBitmapNewQuiet failed.
This commit is contained in:
parent
6c09c17e0d
commit
cb31d618fd
@ -194,13 +194,13 @@ int virHostValidateNamespace(const char *hvname,
|
||||
virBitmapPtr virHostValidateGetCPUFlags(void)
|
||||
{
|
||||
FILE *fp;
|
||||
virBitmapPtr flags;
|
||||
virBitmapPtr flags = NULL;
|
||||
|
||||
if (!(fp = fopen("/proc/cpuinfo", "r")))
|
||||
return NULL;
|
||||
|
||||
if (!(flags = virBitmapNewQuiet(VIR_HOST_VALIDATE_CPU_FLAG_LAST)))
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
|
||||
do {
|
||||
char line[1024];
|
||||
@ -246,6 +246,7 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
|
||||
virStringFreeListCount(tokens, ntokens);
|
||||
} while (1);
|
||||
|
||||
cleanup:
|
||||
VIR_FORCE_FCLOSE(fp);
|
||||
|
||||
return flags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user