proxy->refcount = 1;
proxy->version = factory->version;
- wl_map_insert_at(&display->objects, 0, id, proxy);
+ if (wl_map_insert_at(&display->objects, 0, id, proxy) == -1) {
+ free(proxy);
+ return NULL;
+ }
return proxy;
}
resource->dispatcher = NULL;
if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) {
- wl_resource_post_error(client->display_resource,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid new id %d", id);
+ if (errno == EINVAL) {
+ wl_resource_post_error(client->display_resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "invalid new id %d", id);
+ }
free(resource);
return NULL;
}
WL_MAP_ENTRY_LEGACY, resource);
} else if (wl_map_insert_at(&client->objects, WL_MAP_ENTRY_LEGACY,
resource->object.id, resource) < 0) {
- wl_resource_post_error(client->display_resource,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid new id %d",
- resource->object.id);
+ if (errno == EINVAL) {
+ wl_resource_post_error(client->display_resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "invalid new id %d",
+ resource->object.id);
+ }
return 0;
}