On Fri, 13 May 2016 15:01:21 +0200 Marek Chalupa <[email protected]> wrote:
> while client is being destroyed, it destroys all its resources. > Destroy handlers are called for the resources and if some > destroy handler post no memory error, we get crash, because > the display resource is NULL (it is destroyed as a first resource) > > Signed-off-by: Marek Chalupa <[email protected]> > --- > tests/client-test.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/tests/client-test.c b/tests/client-test.c > index 2e332f8..cb08e39 100644 > --- a/tests/client-test.c > +++ b/tests/client-test.c > @@ -89,3 +89,40 @@ TEST(client_destroy_listener) > wl_display_destroy(display); > } > > +static struct wl_listener seat_destroy_listener; > + > +static void > +seat_destroy_post_no_memory(struct wl_listener *l, void *data) > +{ > + struct wl_resource *resource = data; Add an empty line. > + wl_client_post_no_memory(wl_resource_get_client(resource)); This tests wl_client_post_no_memory(), could it not test wl_resource_post_no_memory() at the same time? > +} > + > +TEST(client_post_nomem_on_destruction) > +{ > + struct wl_display *display; > + struct wl_client *client; > + struct wl_resource *resource; > + int s[2]; > + > + assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0); > + display = wl_display_create(); > + assert(display); > + client = wl_client_create(display, s[0]); > + assert(client); > + > + resource = wl_resource_create(client, &wl_seat_interface, > + wl_seat_interface.version, 0); > + assert(resource); > + > + seat_destroy_listener.notify = seat_destroy_post_no_memory; > + wl_resource_add_destroy_listener(resource, &seat_destroy_listener); > + > + wl_client_destroy(client); > + > + close(s[0]); > + close(s[1]); > + > + wl_display_destroy(display); > +} > + Anyway Reviewed-by: Pekka Paalanen <[email protected]> Thanks, pq
pgpcpcZuTKozu.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
