Reference state when using it as opaque

There should be one more reference because it is being kept in the list
of callbacks as an opaque.  We also unref it properly using
virObjectFreeCallback.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2016-10-11 13:30:11 +02:00
parent 1827f2ac5d
commit 3d279e23e7

View File

@ -870,12 +870,16 @@ virObjectEventStateRegisterID(virConnectPtr conn,
(state->timer = virEventAddTimeout(-1, (state->timer = virEventAddTimeout(-1,
virObjectEventTimer, virObjectEventTimer,
state, state,
NULL)) < 0) { virObjectFreeCallback)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not initialize domain event timer")); _("could not initialize domain event timer"));
goto cleanup; goto cleanup;
} }
/* event loop has one reference, but we need one more for the
* timer's opaque argument */
virObjectRef(state);
ret = virObjectEventCallbackListAddID(conn, state->callbacks, ret = virObjectEventCallbackListAddID(conn, state->callbacks,
key, filter, filter_opaque, key, filter, filter_opaque,
klass, eventID, klass, eventID,