提交 cb31d618 编写于 作者: J John Ferlan

tools: Fix memory leak

Coverity found that commit id 'c661b675' needed to create a cleanup
path to handle the closing of 'fp' if the virBitmapNewQuiet failed.
上级 6c09c17e
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册