From 48523efc7f2e20d9eb77de0e66cc71a76cf4e0ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:37:36 +0000 Subject: [PATCH] Add null check for strdup in dnd_test_drag_notify Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3c7e550c-e8e8-413e-a54b-87d61cb8e574 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> --- kitty/dnd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kitty/dnd.c b/kitty/dnd.c index dae8fcb1f..e0a52d5b1 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -2146,9 +2146,10 @@ dnd_test_drag_notify(PyObject *self UNUSED, PyObject *args) { Window *w = window_for_window_id((id_type)window_id); if (!w) { PyErr_SetString(PyExc_ValueError, "Window not found"); return NULL; } if (type < 0 || type > 3) { PyErr_SetString(PyExc_ValueError, "Invalid type"); return NULL; } - if (accepted_mime) { + if (accepted_mime && *accepted_mime) { free(global_state.drag_source.accepted_mime_type); global_state.drag_source.accepted_mime_type = strdup(accepted_mime); + if (!global_state.drag_source.accepted_mime_type) { PyErr_NoMemory(); return NULL; } } global_state.drag_source.action = action; global_state.drag_source.was_canceled = was_canceled;