diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 6ef9d986569cced2ae39e0d14880674d6ab2b657..a5b349a862e54a85a00262e022d3b4867d70c4be 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -135,22 +135,24 @@ bhyveConnectGetCapabilities(virConnectPtr conn) { bhyveConnPtr privconn = conn->privateData; virCapsPtr caps; - char *xml; + char *xml = NULL; if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL; - caps = bhyveDriverGetCapabilities(privconn); - if (!caps) + if (!(caps = bhyveDriverGetCapabilities(privconn))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to get Capabilities")); + goto cleanup; + } - if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL) { - virObjectUnref(caps); + if (!(xml = virCapabilitiesFormatXML(caps))) { virReportOOMError(); + goto cleanup; } - virObjectUnref(caps); + cleanup: + virObjectUnref(caps); return xml; }