[glib] registrybackend: do not leak key and event if it cannot add the watch



commit 31aab1bd429605a54d3763e3bd0c96b8da45fe38
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Jan 26 12:53:56 2016 +0100

    registrybackend: do not leak key and event if it cannot add the watch

 gio/gregistrysettingsbackend.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c
index fa9ab19..d7ff1c6 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]