drm-lease-v1: fix error codepath

We were crashing in the error codepath [1] when
wlr_drm_create_lease() fails.

To fix this, delay the creation of the wlr_drm_lease_v1 until the
request is granted. Previously we were allocating that struct early
without populating the drm_lease field. However that means we ended
up with a half-constructed struct in the error codepath which is
annoying to handle.

[1]: https://github.com/swaywm/sway/issues/7204#issuecomment-1269797356
This commit is contained in:
Simon Ser 2022-10-07 18:15:24 +02:00 committed by Simon Zeni
parent 3be6658ee7
commit 5c382f6344
2 changed files with 16 additions and 22 deletions

View file

@ -71,8 +71,7 @@ struct wlr_drm_lease_request_v1 {
struct wlr_drm_lease_connector_v1 **connectors;
size_t n_connectors;
/** NULL until the lease is submitted */
struct wlr_drm_lease_v1 *lease;
struct wl_resource *lease_resource;
bool invalid;