mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-08 13:29:47 -05:00
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.
This commit is contained in:
parent
e0680250e6
commit
4f9cf6ec44
1 changed files with 15 additions and 1 deletions
|
|
@ -806,6 +806,19 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
return NULL;
|
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
|
int
|
||||||
wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
|
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 &&
|
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), "
|
printf("invalid object (%u), type (%s), "
|
||||||
"message %s(%s)\n",
|
"message %s(%s)\n",
|
||||||
id, (*object)->interface->name,
|
id, (*object)->interface->name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue