From d75688b0bd804b7c5f84178bbc139982a2a0ab39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 31 Jan 2021 11:38:56 +0100 Subject: [PATCH] =?UTF-8?q?url-mode:=20fix=20=E2=80=98n=E2=80=99=20paramet?= =?UTF-8?q?er=20to=20wcstombs()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- url-mode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/url-mode.c b/url-mode.c index aabb9032..0f23845c 100644 --- a/url-mode.c +++ b/url-mode.c @@ -87,12 +87,16 @@ urls_input(struct seat *seat, struct terminal *term, uint32_t key, if (match) { size_t chars = wcstombs(NULL, match->url, 0); - char url_utf8[chars + 1]; - wcstombs(url_utf8, match->url, chars); + if (chars != (size_t)-1) { + char url_utf8[chars + 1]; + wcstombs(url_utf8, match->url, chars + 1); + spawn(term->reaper, term->cwd, (char *const[]){"xdg-open", url_utf8, NULL}, -1, -1, -1); + } - spawn(term->reaper, term->cwd, (char *const[]){"xdg-open", url_utf8, NULL}, -1, -1, -1); urls_reset(term); - } else if (is_valid) { + } + + else if (is_valid) { xassert(seq_len + 1 <= ALEN(term->url_keys)); term->url_keys[seq_len] = wc; }