diff --git a/docs/changelog.rst b/docs/changelog.rst index b1291567b..783f0024d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,9 @@ To update |kitty|, :doc:`follow the instructions `. - 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`) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 86d4cdfd5..2c32adf1b 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -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,