On Sat, Aug 9, 2014 at 3:14 PM, Pekka Paalanen <ppaala...@gmail.com> wrote:

> I see nothing wrong here, memset to zero is a usual pattern, and
> wl_proxy is a complex enough type, that checking every member is
> set is tedious. Therefore:
>
> Reviewed-by: Pekka Paalanen <ppaala...@gmail.com>
>

Thanks!


> But I do wonder, if it ever makes sense to check user data for
> NULL, and set if it is NULL. If user_data is NULL, how can you
> ever be sure, that the wl_proxy was created by your code, and not
> by some library you use?
>
> Even when user_data is not NULL, you should have some explicit way
> of checking whether the pointer is yours or not.
>

If I would use any external libraries (like Qt or something), I agree that I
could not possibly trust the value of user_data, since I don't know, what
the library is doing there.

But I'm not using any external libraries, just libwayland-client. I thought
that all proxies that are created by marshal_constructor or come from
events with new_id type arguments are created by either of these two
functions and therefore would have a NULL user_data if they got
initialised there. If this is wrong, please tell me. :)


> An example: you use a library and you passed the wl_display to it.
> This library goes and creates a wl_surface of its own. This
> wl_surface gets targeted by input, so your client receives e.g.
> wl_pointer.enter. In the wl_pointer.enter handler, you now suddenly
> have a wl_proxy for a wl_surface that you did not create, and
> therefore the user_data is nothing you would expect. If you are
> lucky, your program crashes here.
>
> The problems emerges in all event handlers, where the event carries
> an object as an argument.
>
>
> Thanks,
> pq
>
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to