perl: Decrement refcount in $g->delete_event_callback.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 22 Apr 2011 20:34:08 +0000 (21:34 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 22 Apr 2011 20:50:15 +0000 (21:50 +0100)
This updates commit bc468c87d04b34faacd208c49cca4a5096e5103c.

generator/generator_perl.ml

index c832469..e2ec254 100644 (file)
@@ -256,11 +256,15 @@ delete_event_callback (g, event_handle)
       int event_handle;
 PREINIT:
       char key[64];
+      SV *cb;
    CODE:
       snprintf (key, sizeof key, \"_perl_event_%%d\", event_handle);
-      guestfs_set_private (g, key, NULL);
-
-      guestfs_delete_event_callback (g, event_handle);
+      cb = guestfs_get_private (g, key);
+      if (cb) {
+        SvREFCNT_dec (cb);
+        guestfs_set_private (g, key, NULL);
+        guestfs_delete_event_callback (g, event_handle);
+      }
 
 SV *
 last_errno (g)