Wayland: Fix handling of clipboard set to self
Passing any part of the result of glfwGetClipboardString to glfwSetClipboardString would result in, at best, a use-after-free error.
This commit is contained in:
parent
920d110b6c
commit
9c95cfb9f1
@ -310,6 +310,8 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN`
|
- [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN`
|
||||||
- [Wayland] Bugfix: Text input did not repeat along with key repeat
|
- [Wayland] Bugfix: Text input did not repeat along with key repeat
|
||||||
- [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521)
|
- [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521)
|
||||||
|
- [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of
|
||||||
|
`glfwGetClipboardString`
|
||||||
- [POSIX] Removed use of deprecated function `gettimeofday`
|
- [POSIX] Removed use of deprecated function `gettimeofday`
|
||||||
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
||||||
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
|
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
|
||||||
|
@ -1664,20 +1664,18 @@ void _glfwSetClipboardStringWayland(const char* string)
|
|||||||
_glfw.wl.dataSource = NULL;
|
_glfw.wl.dataSource = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.wl.clipboardSendString)
|
char* copy = _glfw_strdup(string);
|
||||||
|
if (!copy)
|
||||||
{
|
{
|
||||||
_glfw_free(_glfw.wl.clipboardSendString);
|
_glfwInputError(GLFW_OUT_OF_MEMORY,
|
||||||
_glfw.wl.clipboardSendString = NULL;
|
"Wayland: Failed to allocate clipboard string");
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.wl.clipboardSendString = _glfw_strdup(string);
|
|
||||||
if (!_glfw.wl.clipboardSendString)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Wayland: Impossible to allocate clipboard string");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_glfw.wl.clipboardSendSize = strlen(string);
|
|
||||||
|
_glfw_free(_glfw.wl.clipboardSendString);
|
||||||
|
_glfw.wl.clipboardSendString = copy;
|
||||||
|
|
||||||
|
_glfw.wl.clipboardSendSize = strlen(_glfw.wl.clipboardSendString);
|
||||||
_glfw.wl.dataSource =
|
_glfw.wl.dataSource =
|
||||||
wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
|
wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
|
||||||
if (!_glfw.wl.dataSource)
|
if (!_glfw.wl.dataSource)
|
||||||
|
Loading…
Reference in New Issue
Block a user