Hi!

Because the other thread got so long, I repost the improved version of
the patch for easier review:


>From 50cdeaf09a9bd90b1957a831217319e863c4c484 Mon Sep 17 00:00:00 2001
From: "Nils Chr. Brause" <nilschrbra...@googlemail.com>
Date: Mon, 25 Aug 2014 09:46:55 +0200
Subject: [PATCH] wayland-client: Initialize newly created wl_proxys to zero.

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. Also, after a memset members don't have to be
explicitly initialized with zero anymore.

Signed-off-by: Nils Chr. Brause <nilschrbra...@googlemail.com>
---
 src/wayland-client.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 9159ee0..88ee2dd 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -270,12 +270,11 @@ 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;
        proxy->display = display;
        proxy->queue = factory->queue;
-       proxy->flags = 0;
        proxy->refcount = 1;
 
        proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy);
@@ -327,13 +326,12 @@ 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;
-       proxy->dispatcher = NULL;
        proxy->display = display;
        proxy->queue = factory->queue;
-       proxy->flags = 0;
        proxy->refcount = 1;
 
        wl_map_insert_at(&display->objects, 0, id, proxy);
-- 
2.1.0
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to