<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Aug 9, 2014 at 3:14 PM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I see nothing wrong here, memset to zero is a usual pattern, and<br>
wl_proxy is a complex enough type, that checking every member is<br>
set is tedious. Therefore:<br>
<br>
Reviewed-by: Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>><br></blockquote><div><br></div><div>Thanks!<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But I do wonder, if it ever makes sense to check user data for<br>
NULL, and set if it is NULL. If user_data is NULL, how can you<br>
ever be sure, that the wl_proxy was created by your code, and not<br>
by some library you use?<br>
<br>
Even when user_data is not NULL, you should have some explicit way<br>
of checking whether the pointer is yours or not.<br></blockquote><div><br></div><div>If I would use any external libraries (like Qt or something), I agree that I<br></div><div>could not possibly trust the value of user_data, since I don't know, what<br>
</div><div>the library is doing there.<br><br></div><div>But I'm not using any external libraries, just libwayland-client. I thought<br></div><div>that all proxies that are created by marshal_constructor or come from<br>
</div><div>events with new_id type arguments are created by either of these two<br>functions and therefore would have a NULL user_data if they got<br>initialised there. If this is wrong, please tell me. :)<br></div><div> <br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
An example: you use a library and you passed the wl_display to it.<br>
This library goes and creates a wl_surface of its own. This<br>
wl_surface gets targeted by input, so your client receives e.g.<br>
wl_pointer.enter. In the wl_pointer.enter handler, you now suddenly<br>
have a wl_proxy for a wl_surface that you did not create, and<br>
therefore the user_data is nothing you would expect. If you are<br>
lucky, your program crashes here.<br>
<br>
The problems emerges in all event handlers, where the event carries<br>
an object as an argument.<br>
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div><br></div></div>