data-device.c: Handle OOM in weston_data_source_send_offer()
If we fail to allocate the resource, clean up and return NULL.
diff --git a/src/data-device.c b/src/data-device.c
index 2000f90..4e3f4fc 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -120,6 +120,11 @@
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);