From 605a6a9edeebccd0edf2e1de109449f52b52a9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 13 Jun 2022 12:07:24 +0200 Subject: [PATCH] =?UTF-8?q?particle/string:=20don=E2=80=99t=20try=20to=20c?= =?UTF-8?q?all=20c32len()=20on=20a=20NULL=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ particles/string.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9286a76..d72d692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,8 @@ device yambar is already tracking ([#177][177]). * Crash when a particle is “too wide”, and tries to render outside the bar ([#198][198]). +* string: crash when failing to convert string to UTF-32. + [169]: https://codeberg.org/dnkl/yambar/issues/169 [172]: https://codeberg.org/dnkl/yambar/issues/172 diff --git a/particles/string.c b/particles/string.c index 190a786..e679600 100644 --- a/particles/string.c +++ b/particles/string.c @@ -176,7 +176,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags) /* Not in cache - we need to rasterize it. First, convert to char32_t */ wtext = ambstoc32(text); - size_t chars = c32len(wtext); + size_t chars = wtext != NULL ? c32len(wtext) : 0; /* Truncate, if necessary */ if (p->max_len > 0 && chars > p->max_len) {