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 f48fa604b0)
This commit is contained in:
Frank Praznik
2026-09-04 12:43:59 -04:00
parent 44a04139e3
commit 1efd4a8ffc

View File

@@ -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) {