From 1efd4a8ffc334acda17e02739117c6ddd45dde2f Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 4 Sep 2026 12:43:59 -0400 Subject: [PATCH] x11: Clear the internal selection data when updating the clipboard Clear the internal X11 clipboard selection data when updating the clipboard during SelectionNotify events, as it is invalid after the update. Otherwise, an out-of-date SelectionRequest can end up attempting to read the invalid data, and cause a crash. (cherry picked from commit f48fa604b0a74175d589d5c1f3189504e085adc2) --- src/video/x11/SDL_x11events.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 41b06d02db..35d9c106ff 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -947,6 +947,9 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven new_mime_types[length] = NULL; SDL_SendClipboardUpdate(false, new_mime_types, length); + + // Clear the internal selection source data, as it was invalided after updating the clipboard. + SDL_zero(videodata->clipboard); } if (data) {