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

conf: Fix resource leak in virCapabilitiesInitCaches

The @type from virFileReadValueString needs to be VIR_FREE each time
through the loop since it's not saved and since cleanup can be reached
prior to decoding it for @kernel_type amd bank->type, the cleanup code
needs to also have a VIR_FREE

Found by Coverity
上级 53d3f8b2
...@@ -1611,10 +1611,10 @@ virCapabilitiesInitCaches(virCapsPtr caps) ...@@ -1611,10 +1611,10 @@ virCapabilitiesInitCaches(virCapsPtr caps)
if (kernel_type < 0) { if (kernel_type < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown cache type '%s'"), type); _("Unknown cache type '%s'"), type);
VIR_FREE(type);
goto cleanup; goto cleanup;
} }
bank->type = kernel_type; bank->type = kernel_type;
VIR_FREE(type);
for (i = 0; i < caps->host.ncaches; i++) { for (i = 0; i < caps->host.ncaches; i++) {
if (virCapsHostCacheBankEquals(bank, caps->host.caches[i])) if (virCapsHostCacheBankEquals(bank, caps->host.caches[i]))
...@@ -1637,6 +1637,7 @@ virCapabilitiesInitCaches(virCapsPtr caps) ...@@ -1637,6 +1637,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(type);
VIR_FREE(path); VIR_FREE(path);
virDirClose(&dirp); virDirClose(&dirp);
virCapsHostCacheBankFree(bank); virCapsHostCacheBankFree(bank);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册