From 403931ed22a3ea7f02913500bf5471bc069dc23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 6 Aug 2013 10:24:04 -0700 Subject: [PATCH] data-device.c: Handle OOM in wl_data_source_send_offer() If we fail to allocate the resource, clean up and return NULL. --- src/data-device.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/data-device.c b/src/data-device.c index c89379c87..353abb6ed 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -120,6 +120,11 @@ wl_data_source_send_offer(struct wl_data_source *source, offer->resource = wl_resource_create(wl_resource_get_client(target), &wl_data_offer_interface, 1, 0); + if (offer->resource == NULL) { + free(offer); + return NULL; + } + wl_resource_set_implementation(offer->resource, &data_offer_interface, offer, destroy_data_offer);