From f3cda7e828730053164b99a7c94f77b0d4d77193 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 8 Feb 2026 14:10:32 +0530 Subject: [PATCH] Have mimes_count be always accurate --- glfw/wl_window.c | 4 ++++ kitty/glfw.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 361ffde92..cf3afe613 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -2452,6 +2452,10 @@ static void handle_primary_selection_offer(void *data UNUSED, struct zwp_primary // Helper function to update drop state from callback results static void update_drop_state(_GLFWWaylandDataOffer *d, _GLFWwindow* window UNUSED, size_t mime_count) { + for (size_t i = mime_count; i < d->mimes_count; i++) { + if (d->mimes[i]) { free((void*)d->mimes[i]); d->mimes[i] = NULL; } + } + d->mimes_count = mime_count; bool accepted = mime_count > 0; bool acceptance_changed = (accepted != d->drag_accepted); // The first MIME in the sorted list is the preferred one for drop diff --git a/kitty/glfw.c b/kitty/glfw.c index ce5688fa7..8eeb6e865 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -693,7 +693,7 @@ read_drop_data(GLFWwindow *window, GLFWDropEvent *ev) { global_state.drop_dest.num_left--; if (!global_state.drop_dest.num_left) { WINDOW_CALLBACK(on_drop, "OOii", global_state.drop_dest.data, Py_False, - global_state.callback_os_window->last_drag_event.x, global_state.callback_os_window->last_drag_event.y); + global_state.callback_os_window->last_drag_event.x, global_state.callback_os_window->last_drag_event.y); finish(true); } } else if (ret > 0) {