[glib] registrybackend: do not leak the watch data in case of failure



commit bad7e4a1149b9bad2385fe1818040f55f3e385c5
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Jan 26 13:15:51 2016 +0100

    registrybackend: do not leak the watch data in case of failure

 gio/gregistrysettingsbackend.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c
index d7ff1c6..21e9a63 100644
--- a/gio/gregistrysettingsbackend.c
+++ b/gio/gregistrysettingsbackend.c
@@ -1706,7 +1706,7 @@ watch_start (GRegistryBackend *self)
   if (watch->message_sent_event == NULL || watch->message_received_event == NULL)
     {
       g_message_win32_error (0, "gregistrybackend: Failed to create sync objects.");
-      goto fail_1;
+      goto fail;
     }
 
   /* Use a small stack to make the thread more lightweight. */
@@ -1714,20 +1714,22 @@ watch_start (GRegistryBackend *self)
   if (watch->thread == NULL)
     {
       g_message_win32_error (0, "gregistrybackend: Failed to create notify watch thread.");
-      goto fail_2;
+      goto fail;
     }
 
   self->watch = watch;
 
   return TRUE;
 
-fail_2:
+fail:
   DeleteCriticalSection (watch->message_lock);
   g_slice_free (CRITICAL_SECTION, watch->message_lock);
-  CloseHandle (watch->message_sent_event);
-  CloseHandle (watch->message_received_event);
-fail_1:
+  if (watch->message_sent_event != NULL)
+    CloseHandle (watch->message_sent_event);
+  if (watch->message_received_event != NULL)
+    CloseHandle (watch->message_received_event);
   g_slice_free (WatchThreadState, watch);
+
   return FALSE;
 }
 


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