From dac1ba18c8e97e2a726a83e1cddc1c8f2a40468d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 1 Nov 2019 20:25:44 +0100 Subject: [PATCH] render: limit length of title in call to xdg_toplevel_set_title() Trying to pass a too long title (not sure what "too long" is though...) will trigger a call to abort() inside the wayland-client library. --- render.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/render.c b/render.c index b58eb7dc..2386e073 100644 --- a/render.c +++ b/render.c @@ -950,9 +950,21 @@ render_resize(struct terminal *term, int width, int height) } void -render_set_title(struct terminal *term, const char *title) +render_set_title(struct terminal *term, const char *_title) { + /* TODO: figure out what the limit actually is */ + static const size_t max_len = 100; + + const char *title = _title; + char *copy = NULL; + + if (strlen(title) > max_len) { + copy = strndup(_title, max_len); + title = copy; + } + xdg_toplevel_set_title(term->window->xdg_toplevel, title); + free(copy); } void