registrybackend: do not leak self if there are no items

This commit is contained in:
Ignacio Casal Quinteiro 2016-02-04 11:16:45 +01:00
parent dc97bb9b9b
commit 74442a0b8c

View File

@ -1732,10 +1732,8 @@ watch_thread_function (LPVOID parameter)
* likely to block (only when changing notification subscriptions). * likely to block (only when changing notification subscriptions).
*/ */
event = g_slice_new (RegistryEvent); event = g_slice_new (RegistryEvent);
event->self = g_object_ref (self->owner);
event->self = G_REGISTRY_BACKEND (self->owner); event->prefix = g_strdup (prefix);
g_object_ref (self->owner);
event->items = g_ptr_array_new_with_free_func (g_free); event->items = g_ptr_array_new_with_free_func (g_free);
EnterCriticalSection (G_REGISTRY_BACKEND (self->owner)->cache_lock); EnterCriticalSection (G_REGISTRY_BACKEND (self->owner)->cache_lock);
@ -1744,12 +1742,11 @@ watch_thread_function (LPVOID parameter)
LeaveCriticalSection (G_REGISTRY_BACKEND (self->owner)->cache_lock); LeaveCriticalSection (G_REGISTRY_BACKEND (self->owner)->cache_lock);
if (event->items->len > 0) if (event->items->len > 0)
{ g_idle_add ((GSourceFunc) watch_handler, event);
event->prefix = g_strdup (prefix);
g_idle_add ((GSourceFunc) watch_handler, event);
}
else else
{ {
g_object_unref (event->self);
g_free (event->prefix);
g_ptr_array_free (event->items, TRUE); g_ptr_array_free (event->items, TRUE);
g_slice_free (RegistryEvent, event); g_slice_free (RegistryEvent, event);
} }