diff --git a/src/x11_window.c b/src/x11_window.c index 23dc89ad..89356671 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2997,8 +2997,9 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetClipboardString(const char* string) { + char* copy = _glfw_strdup(string); free(_glfw.x11.clipboardString); - _glfw.x11.clipboardString = _glfw_strdup(string); + _glfw.x11.clipboardString = copy; XSetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD,