From 3c30f0f950a616df4c899c57839ef34946ead8b1 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 weston_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 2000f90e..4e3f4fc0 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -120,6 +120,11 @@ weston_data_source_send_offer(struct weston_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);