[Telepathy-commits] [telepathy-gabble/master] fd.o#20003: GabbleJingle*: use GPOINTER_TO_SIZE for GTypes

Simon McVittie simon.mcvittie at collabora.co.uk
Sun Feb 8 05:39:20 PST 2009


This fixes a crash when the GType is instantiated on certain 64-bit
platforms. GType is defined to be the same size as gsize, which may
be greater than the size of int. On some 64-bit platforms (including
amd64 Linux?) the high bits of a GType are in practice zero anyway, so
the truncation is wrong but harmless and we didn't see this crash; on
other 64-bit platforms, we crash.
---
 src/jingle-content.c |    6 +++---
 src/jingle-factory.c |    4 ++--
 src/jingle-session.c |    4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/jingle-content.c b/src/jingle-content.c
index 4071bfc..ad84fd3 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -217,7 +217,7 @@ gabble_jingle_content_set_property (GObject *object,
 
       if (priv->transport_ns != NULL)
         {
-          GType transport_type = GPOINTER_TO_INT (
+          GType transport_type = GPOINTER_TO_SIZE (
               g_hash_table_lookup (self->conn->jingle_factory->transports,
                   priv->transport_ns));
 
@@ -480,7 +480,7 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
 
           dialect = JINGLE_DIALECT_GTALK3;
           g_object_set (c->session, "dialect", JINGLE_DIALECT_GTALK3, NULL);
-          transport_type = GPOINTER_TO_INT (
+          transport_type = GPOINTER_TO_SIZE (
               g_hash_table_lookup (c->conn->jingle_factory->transports, ""));
           priv->transport_ns = g_strdup ("");
         }
@@ -499,7 +499,7 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
     {
       const gchar *ns = lm_message_node_get_namespace (trans_node);
 
-      transport_type = GPOINTER_TO_INT (
+      transport_type = GPOINTER_TO_SIZE (
           g_hash_table_lookup (c->conn->jingle_factory->transports, ns));
 
       if (transport_type == 0)
diff --git a/src/jingle-factory.c b/src/jingle-factory.c
index 7e226e0..c26e536 100644
--- a/src/jingle-factory.c
+++ b/src/jingle-factory.c
@@ -607,7 +607,7 @@ gabble_jingle_factory_register_transport (GabbleJingleFactory *factory,
     gchar *namespace, GType transport_type)
 {
   g_hash_table_insert (factory->transports, namespace,
-      GINT_TO_POINTER (transport_type));
+      GSIZE_TO_POINTER (transport_type));
 }
 
 void
@@ -615,7 +615,7 @@ gabble_jingle_factory_register_content_type (GabbleJingleFactory *factory,
     gchar *namespace, GType content_type)
 {
   g_hash_table_insert (factory->content_types, namespace,
-      GINT_TO_POINTER (content_type));
+      GSIZE_TO_POINTER (content_type));
 }
 
 static void
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 8e51102..c6bcbca 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -610,7 +610,7 @@ _each_content_add (GabbleJingleSession *sess, GabbleJingleContent *c,
       content_ns = lm_message_node_get_namespace (desc_node);
       DEBUG ("namespace: %s", content_ns);
       content_type =
-          GPOINTER_TO_INT (g_hash_table_lookup (priv->conn->jingle_factory->content_types,
+          GPOINTER_TO_SIZE (g_hash_table_lookup (priv->conn->jingle_factory->content_types,
           content_ns));
     }
 
@@ -1609,7 +1609,7 @@ gabble_jingle_session_add_content (GabbleJingleSession *sess, JingleMediaType mt
   while (g_hash_table_lookup (priv->contents, name) != NULL);
 
   content_type =
-      GPOINTER_TO_INT (g_hash_table_lookup (priv->conn->jingle_factory->content_types,
+      GPOINTER_TO_SIZE (g_hash_table_lookup (priv->conn->jingle_factory->content_types,
       content_ns));
 
   g_assert (content_type != 0);
-- 
1.5.6.5




More information about the telepathy-commits mailing list