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.
This commit is contained in:
+32
-7
@@ -1492,9 +1492,14 @@ surface_frame(struct wl_client *client,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb->resource = wl_resource_create(client,
|
cb->resource = wl_resource_create(client, &wl_callback_interface, 1,
|
||||||
&wl_callback_interface,
|
callback);
|
||||||
1, callback);
|
if (cb->resource == NULL) {
|
||||||
|
free(cb);
|
||||||
|
wl_resource_post_no_memory(resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_resource_set_implementation(cb->resource, NULL, cb,
|
wl_resource_set_implementation(cb->resource, NULL, cb,
|
||||||
destroy_frame_callback);
|
destroy_frame_callback);
|
||||||
|
|
||||||
@@ -1696,6 +1701,11 @@ compositor_create_surface(struct wl_client *client,
|
|||||||
surface->resource =
|
surface->resource =
|
||||||
wl_resource_create(client, &wl_surface_interface,
|
wl_resource_create(client, &wl_surface_interface,
|
||||||
wl_resource_get_version(resource), id);
|
wl_resource_get_version(resource), id);
|
||||||
|
if (surface->resource == NULL) {
|
||||||
|
weston_surface_destroy(surface);
|
||||||
|
wl_resource_post_no_memory(resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
wl_resource_set_implementation(surface->resource, &surface_interface,
|
wl_resource_set_implementation(surface->resource, &surface_interface,
|
||||||
surface, destroy_surface);
|
surface, destroy_surface);
|
||||||
}
|
}
|
||||||
@@ -1759,6 +1769,11 @@ compositor_create_region(struct wl_client *client,
|
|||||||
|
|
||||||
region->resource =
|
region->resource =
|
||||||
wl_resource_create(client, &wl_region_interface, 1, id);
|
wl_resource_create(client, &wl_region_interface, 1, id);
|
||||||
|
if (region->resource == NULL) {
|
||||||
|
free(region);
|
||||||
|
wl_resource_post_no_memory(resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
wl_resource_set_implementation(region->resource, ®ion_interface,
|
wl_resource_set_implementation(region->resource, ®ion_interface,
|
||||||
region, destroy_region);
|
region, destroy_region);
|
||||||
}
|
}
|
||||||
@@ -2419,9 +2434,11 @@ bind_subcompositor(struct wl_client *client,
|
|||||||
|
|
||||||
resource =
|
resource =
|
||||||
wl_resource_create(client, &wl_subcompositor_interface, 1, id);
|
wl_resource_create(client, &wl_subcompositor_interface, 1, id);
|
||||||
if (resource)
|
if (resource == NULL) {
|
||||||
wl_resource_set_implementation(resource,
|
wl_client_post_no_memory(client);
|
||||||
&subcompositor_interface,
|
return;
|
||||||
|
}
|
||||||
|
wl_resource_set_implementation(resource, &subcompositor_interface,
|
||||||
compositor, NULL);
|
compositor, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2542,6 +2559,10 @@ bind_output(struct wl_client *client,
|
|||||||
|
|
||||||
resource = wl_resource_create(client, &wl_output_interface,
|
resource = wl_resource_create(client, &wl_output_interface,
|
||||||
MIN(version, 2), id);
|
MIN(version, 2), id);
|
||||||
|
if (resource == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_list_insert(&output->resource_list, wl_resource_get_link(resource));
|
wl_list_insert(&output->resource_list, wl_resource_get_link(resource));
|
||||||
wl_resource_set_implementation(resource, NULL, data, unbind_resource);
|
wl_resource_set_implementation(resource, NULL, data, unbind_resource);
|
||||||
@@ -2813,7 +2834,11 @@ compositor_bind(struct wl_client *client,
|
|||||||
|
|
||||||
resource = wl_resource_create(client, &wl_compositor_interface,
|
resource = wl_resource_create(client, &wl_compositor_interface,
|
||||||
MIN(version, 3), id);
|
MIN(version, 3), id);
|
||||||
if (resource)
|
if (resource == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_resource_set_implementation(resource, &compositor_interface,
|
wl_resource_set_implementation(resource, &compositor_interface,
|
||||||
compositor, NULL);
|
compositor, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -577,8 +577,13 @@ get_data_device(struct wl_client *client,
|
|||||||
|
|
||||||
resource = wl_resource_create(client,
|
resource = wl_resource_create(client,
|
||||||
&wl_data_device_interface, 1, id);
|
&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,
|
wl_resource_set_implementation(resource, &data_device_interface,
|
||||||
seat, unbind_data_device);
|
seat, unbind_data_device);
|
||||||
}
|
}
|
||||||
@@ -597,7 +602,11 @@ bind_manager(struct wl_client *client,
|
|||||||
resource =
|
resource =
|
||||||
wl_resource_create(client,
|
wl_resource_create(client,
|
||||||
&wl_data_device_manager_interface, 1, id);
|
&wl_data_device_manager_interface, 1, id);
|
||||||
if (resource)
|
if (resource == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_resource_set_implementation(resource, &manager_interface,
|
wl_resource_set_implementation(resource, &manager_interface,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -1177,6 +1177,11 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
|
|||||||
|
|
||||||
cr = wl_resource_create(client, &wl_pointer_interface,
|
cr = wl_resource_create(client, &wl_pointer_interface,
|
||||||
wl_resource_get_version(resource), id);
|
wl_resource_get_version(resource), id);
|
||||||
|
if (cr == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_list_insert(&seat->pointer->resource_list, wl_resource_get_link(cr));
|
wl_list_insert(&seat->pointer->resource_list, wl_resource_get_link(cr));
|
||||||
wl_resource_set_implementation(cr, &pointer_interface, seat->pointer,
|
wl_resource_set_implementation(cr, &pointer_interface, seat->pointer,
|
||||||
unbind_resource);
|
unbind_resource);
|
||||||
@@ -1211,6 +1216,11 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource,
|
|||||||
|
|
||||||
cr = wl_resource_create(client, &wl_keyboard_interface,
|
cr = wl_resource_create(client, &wl_keyboard_interface,
|
||||||
wl_resource_get_version(resource), id);
|
wl_resource_get_version(resource), id);
|
||||||
|
if (cr == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr));
|
wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr));
|
||||||
wl_resource_set_implementation(cr, NULL, seat, unbind_resource);
|
wl_resource_set_implementation(cr, NULL, seat, unbind_resource);
|
||||||
|
|
||||||
@@ -1246,6 +1256,11 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource,
|
|||||||
|
|
||||||
cr = wl_resource_create(client, &wl_touch_interface,
|
cr = wl_resource_create(client, &wl_touch_interface,
|
||||||
wl_resource_get_version(resource), id);
|
wl_resource_get_version(resource), id);
|
||||||
|
if (cr == NULL) {
|
||||||
|
wl_client_post_no_memory(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_list_insert(&seat->touch->resource_list, wl_resource_get_link(cr));
|
wl_list_insert(&seat->touch->resource_list, wl_resource_get_link(cr));
|
||||||
wl_resource_set_implementation(cr, NULL, seat, unbind_resource);
|
wl_resource_set_implementation(cr, NULL, seat, unbind_resource);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user