[glib/glib-2-26] GSocketControlMessage: clean up confusing code



commit 8d5922ab6560d3fa64ad25777834720aab6d50e9
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Sep 22 06:45:02 2010 -0400

    GSocketControlMessage: clean up confusing code
    
    It looks like the deserialisation function in GSocketControlMessage can
    potentially leak a reference to the class structure of a
    GSocketControlMessage subclass (although the particular code path is
    probably never hit).
    
    Clean up the code a bit.
    
    Also, make sure that the GUnixCredentialsMessage type is registered
    before attempting deserialisation.
    
    Closes bug #629687.

 gio/gsocketcontrolmessage.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/gio/gsocketcontrolmessage.c b/gio/gsocketcontrolmessage.c
index 19a62b6..a1879bb 100644
--- a/gio/gsocketcontrolmessage.c
+++ b/gio/gsocketcontrolmessage.c
@@ -48,6 +48,7 @@
 #include "glibintl.h"
 
 #ifndef G_OS_WIN32
+#include "gunixcredentialsmessage.h"
 #include "gunixfdmessage.h"
 #endif
 
@@ -172,7 +173,6 @@ g_socket_control_message_deserialize (int      level,
 				      gsize    size,
 				      gpointer data)
 {
-  GSocketControlMessageClass *klass;
   GSocketControlMessage *message;
   GType *message_types;
   guint n_message_types;
@@ -183,6 +183,7 @@ g_socket_control_message_deserialize (int      level,
 
   /* Ensure we know about the built in types */
 #ifndef G_OS_WIN32
+  a_type = g_unix_credentials_message_get_type ();
   a_type = g_unix_fd_message_get_type ();
 #endif
 
@@ -191,16 +192,14 @@ g_socket_control_message_deserialize (int      level,
   message = NULL;
   for (i = 0; i < n_message_types; i++)
     {
-      klass = (GSocketControlMessageClass *)g_type_class_ref (message_types[i]);
+      GSocketControlMessageClass *class;
 
-      if (klass && klass->deserialize)
-	{
-	  message = klass->deserialize (level, type, size, data);
-	  g_type_class_unref ((GTypeClass *) klass);
-	}
+      class = g_type_class_ref (message_types[i]);
+      message = class->deserialize (level, type, size, data);
+      g_type_class_unref (class);
 
       if (message != NULL)
-	break;
+        break;
     }
 
   g_free (message_types);



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