In virCHMontiorNew the monitor object was referenced an additional
time incorrectly preventing it from being disposed of, and wasn't
always closed properly on failure.
Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
if (!vm->def) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("VM is not defined"));
- return NULL;
+ goto cleanup;
}
/* prepare to launch Cloud-Hypervisor socket */
mon->handle = curl_easy_init();
/* now has its own reference */
- virObjectRef(mon);
mon->vm = virObjectRef(vm);
ret = mon;
+ mon = NULL;
cleanup:
+ virCHMonitorClose(mon);
virCommandFree(cmd);
return ret;
}