[PATCH] wayland-client: Initialize newly created wl_proxys to zero.
Marek Chalupa
mchqwerty at gmail.com
Fri Aug 8 10:23:11 PDT 2014
Just out of curiosity, did you have some troubles because of non-setting
the proxy to zeroes?
On 8 August 2014 18:31, Nils Chr. Brause <nilschrbrause at gmail.com> wrote:
> Up until now, newly created wl_proxys (with proxy_create or
> wl_proxy_create_for_id) are not initialized properly after memory
> allocation. The wl_display object in contrast is. To prevent giving
> uninitialized data to the user (e.g. user_data) an appropriate memset
> has been added.
>
Well, user is the one that is responsible for setting user data. If he will
use them uninitialized, it's his fault.
>
> Signed-off-by: Nils Chr. Brause <nilschrbrause at googlemail.com>
> ---
> src/wayland-client.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 3e401d3..8006581 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -274,6 +274,8 @@ proxy_create(struct wl_proxy *factory, const struct
> wl_interface *interface)
> if (proxy == NULL)
> return NULL;
>
> + memset(proxy, 0, sizeof *proxy);
> +
> proxy->object.interface = interface;
> proxy->object.implementation = NULL;
> proxy->dispatcher = NULL;
>
These settings to NULL can be removed when memset is applied.
> @@ -331,6 +333,8 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
> if (proxy == NULL)
> return NULL;
>
> + memset(proxy, 0, sizeof *proxy);
> +
> proxy->object.interface = interface;
> proxy->object.implementation = NULL;
> proxy->object.id = id;
> --
> 2.0.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
Regards,
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140808/f22d70a6/attachment-0001.html>
More information about the wayland-devel
mailing list