Просмотр исходного кода

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.
Frank Praznik 2 недель назад
Родитель
Сommit
f48fa604b0
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      src/video/x11/SDL_x11events.c

+ 3 - 0
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) {