Skip to content

Commit

Permalink
wl: Fix possible invalid access to Platform:popup
Browse files Browse the repository at this point in the history
... inducted by the the xdg_popup::popup_done handler.

This change fixes the `xdg_popup_on_popup_done()` in
platform/wayland/cog-utils-wl.c. Now, the function resets the
the Platform::popup if the destroyed popup is the same than the one
referenced in the Platform.
  • Loading branch information
psaavedra committed Nov 1, 2023
1 parent 0c47295 commit 32c8c80
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platform/wayland/cog-utils-wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ xdg_popup_on_configure(void *data, struct xdg_popup *xdg_popup, int32_t x, int32
static void
xdg_popup_on_popup_done(void *data, struct xdg_popup *xdg_popup)
{
cog_wl_popup_destroy((CogWlPopup *) data);
CogWlPopup *popup = data;
CogWlPlatform *platform = (CogWlPlatform *) cog_platform_get_default();

// Reset the reference in the Platform if the destroyed popup is the same
if (platform->popup == popup)
platform->popup = NULL;

cog_wl_popup_destroy(popup);
}

static void
Expand Down

0 comments on commit 32c8c80

Please sign in to comment.