From 31aab1bd429605a54d3763e3bd0c96b8da45fe38 Mon Sep 17 00:00:00 2001 From: Ignacio Casal Quinteiro Date: Tue, 26 Jan 2016 12:53:56 +0100 Subject: [PATCH] registrybackend: do not leak key and event if it cannot add the watch --- gio/gregistrysettingsbackend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c index fa9ab1948..d7ff1c6fa 100644 --- a/gio/gregistrysettingsbackend.c +++ b/gio/gregistrysettingsbackend.c @@ -1933,7 +1933,11 @@ g_registry_backend_subscribe (GSettingsBackend *backend, /* The actual watch is added by the thread, which has to re-subscribe each time it * receives a change. */ if (!watch_add_notify (self, event, hpath, g_strdup (key_name))) - g_atomic_int_inc (&self->watch->watches_remaining); + { + g_atomic_int_inc (&self->watch->watches_remaining); + RegCloseKey (hpath); + CloseHandle (event); + } } static void