From 712276412a27c3d324678488654962fe5717aa73 Mon Sep 17 00:00:00 2001 From: Sami Farin Date: Tue, 6 Oct 2026 12:56:57 +0300 Subject: [PATCH] toplevel_data_for_drag: check for NULL from as_file_url Avoid segfault in strlen() inside finish_remote_data() if as_file_url returns NULL. --- kitty/dnd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kitty/dnd.c b/kitty/dnd.c index 24dd7e329..40a51b954 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -2462,8 +2462,10 @@ toplevel_data_for_drag( if (fd < 0) abrt(errno, "failed to open directory for drag source item"); ri->top_level_parent_dir_fd_plus_one = fd + 1; if (!ds.file_promises) { + char *new_url = as_file_url(ds.base_dir_for_remote_items, path, ri->dir_entry_name); + if (!new_url) abrt(ENOMEM, "failed to generate file URL for drag source item"); free(mi.uri_list[uri_item_idx]); - mi.uri_list[uri_item_idx] = as_file_url(ds.base_dir_for_remote_items, path, ri->dir_entry_name); + mi.uri_list[uri_item_idx] = new_url; } } return add_payload(w, ri, has_more, payload, payload_sz, ri->top_level_parent_dir_fd_plus_one - 1);