From 4f9cf6ec4465411076d4facf6ab67a272f5183d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 10 Oct 2012 19:25:48 -0400 Subject: [PATCH] Fix typecheck in case of multiple instances of type meta data In most cases the pointer equality test is sufficient. However, in some cases, depending on how things are split across shared objects, we can end up with multiple instances of the interface metadata constants. So if the pointers match, the interfaces are equal, if they don't match we have to compare the interface names. --- src/connection.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/connection.c b/src/connection.c index 0958fe0..f86a892 100644 --- a/src/connection.c +++ b/src/connection.c @@ -806,6 +806,19 @@ wl_connection_demarshal(struct wl_connection *connection, return NULL; } +static int +interface_equal(const struct wl_interface *a, const struct wl_interface *b) +{ + /* In most cases the pointer equality test is sufficient. + * However, in some cases, depending on how things are split + * across shared objects, we can end up with multiple + * instances of the interface metadata constants. So if the + * pointers match, the interfaces are equal, if they don't + * match we have to compare the interface names. */ + + return a == b || strcmp(a->name, b->name) == 0; +} + int wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects) { @@ -839,7 +852,8 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects) } if (*object != NULL && message->types[i-2] != NULL && - (*object)->interface != message->types[i-2]) { + !interface_equal((*object)->interface, + message->types[i-2])) { printf("invalid object (%u), type (%s), " "message %s(%s)\n", id, (*object)->interface->name, -- 2.7.4