Skip to content

Commit

Permalink
Wayland: Fix window titles being set to very long strings on the orde…
Browse files Browse the repository at this point in the history
…r of 8KB causing a crash

Fixes #1526
  • Loading branch information
kovidgoyal committed Jan 27, 2020
1 parent 109a856 commit 2e3037c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Wayland: Fix a freeze in rare circumstances when having multiple OS Windows
(:iss:`2307` and :iss:`1722`)

- Wayland: Fix window titles being set to very long strings on the order of 8KB
causing a crash (:iss:`1526`)

- Add an option :opt:`force_ltr` to turn off the display of text in RTL scripts
in right-to-left order (:pull:`2293`)

Expand Down
6 changes: 5 additions & 1 deletion glfw/wl_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,12 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
if (window->wl.title)
free(window->wl.title);
window->wl.title = _glfw_strdup(title);
// Wayland cannot handle requests larger than ~8200 bytes. Sending
// on causes an abort(). Since titles this large are meaningless anyway
// ensure they do not happen.
if (title && strnlen(title, 2048) >= 2048) window->wl.title[2048] = 0;
if (window->wl.xdg.toplevel)
xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
}

void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,
Expand Down

0 comments on commit 2e3037c

Please sign in to comment.