security: avoid memory leak

Leak introduced in commit d6623003.

* src/qemu/qemu_driver.c (qemuSecurityInit): Avoid leak on failure.
* src/security/security_stack.c (virSecurityStackClose): Avoid
leaking component drivers.
This commit is contained in:
Eric Blake 2011-02-21 15:05:24 -07:00
parent dfd39ccda8
commit 009fce98be
2 changed files with 10 additions and 2 deletions

View File

@ -204,8 +204,11 @@ qemuSecurityInit(struct qemud_driver *driver)
goto error;
if (!(driver->securityManager = virSecurityManagerNewStack(mgr,
dac)))
dac))) {
virSecurityManagerFree(dac);
goto error;
}
} else {
driver->securityManager = mgr;
}

View File

@ -61,8 +61,13 @@ virSecurityStackOpen(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
}
static int
virSecurityStackClose(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
virSecurityStackClose(virSecurityManagerPtr mgr)
{
virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
virSecurityManagerFree(priv->primary);
virSecurityManagerFree(priv->secondary);
return 0;
}