]> xenbits.xensource.com Git - libvirt.git/commitdiff
Reference state when using it as opaque
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 11 Oct 2016 11:30:11 +0000 (13:30 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 12 Oct 2016 10:54:47 +0000 (12:54 +0200)
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>
src/conf/object_event.c

index b859835b47a1e1b0151736b0a0bd48083d231a42..1ef8b58d10c3ea525ad39f779e265c4a58d4131f 100644 (file)
@@ -870,12 +870,16 @@ virObjectEventStateRegisterID(virConnectPtr conn,
         (state->timer = virEventAddTimeout(-1,
                                            virObjectEventTimer,
                                            state,
-                                           NULL)) < 0) {
+                                           virObjectFreeCallback)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("could not initialize domain event timer"));
         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,
                                           key, filter, filter_opaque,
                                           klass, eventID,