From f48fa604b0a74175d589d5c1f3189504e085adc2 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. --- 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 5a2ae42795..b63b2a0eb9 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) {