From 25db8f801475d1d90664077db8390fe573d28e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 19:23:25 +0100 Subject: [PATCH] Wayland: Fix partial writes of clipboard string The string pointer used to write the contents of our clipboard data offer was never updated, causing it to repeat parts of the beginning of the string until the correct number of bytes had been written. (cherry picked from commit 4c110bba41b0df8a3b295fdd5e4e95aed6615001) --- README.md | 1 + src/wl_window.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d406c878..4231914f 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of `glfwGetClipboardString` - [Wayland] Bugfix: Data source creation error would cause double free at termination + - [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat ## Contact diff --git a/src/wl_window.c b/src/wl_window.c index ee4a26f6..ae24626b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1725,7 +1725,7 @@ static void dataSourceHandleSend(void* data, const char* mimeType, int fd) { - const char* string = _glfw.wl.clipboardSendString; + char* string = _glfw.wl.clipboardSendString; size_t len = strlen(string); int ret; @@ -1765,6 +1765,7 @@ static void dataSourceHandleSend(void* data, return; } len -= ret; + string += ret; } close(fd); }