summaryrefslogtreecommitdiff
path: root/src/data-device.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2013-08-06 16:46:25 -0700
committerKristian Høgsberg <krh@bitplanet.net>2013-08-06 16:46:25 -0700
commit0ff790876700d91adf0c323134d5424b3ba49f17 (patch)
treeb4ac60d9d27007a55b4921b80eb8dc13d89782bc /src/data-device.c
parentb10b44b58cb4d7ccfffa6d286e7adb5da89df686 (diff)
downloadweston-0ff790876700d91adf0c323134d5424b3ba49f17.tar.gz
compositor: Check wl_resource_create() return value
This fixes a number of call-sites to properly check for NULL and return the no memory event when allocation fail.
Diffstat (limited to 'src/data-device.c')
-rw-r--r--src/data-device.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/data-device.c b/src/data-device.c
index d05b538b..a76ae169 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -577,8 +577,13 @@ get_data_device(struct wl_client *client,
resource = wl_resource_create(client,
&wl_data_device_interface, 1, id);
+ if (resource == NULL) {
+ wl_resource_post_no_memory(manager_resource);
+ return;
+ }
- wl_list_insert(&seat->drag_resource_list, wl_resource_get_link(resource));
+ wl_list_insert(&seat->drag_resource_list,
+ wl_resource_get_link(resource));
wl_resource_set_implementation(resource, &data_device_interface,
seat, unbind_data_device);
}
@@ -597,9 +602,13 @@ bind_manager(struct wl_client *client,
resource =
wl_resource_create(client,
&wl_data_device_manager_interface, 1, id);
- if (resource)
- wl_resource_set_implementation(resource, &manager_interface,
- NULL, NULL);
+ if (resource == NULL) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource, &manager_interface,
+ NULL, NULL);
}
WL_EXPORT void