From ca47ffee9cdaba6c2d96f3e3f62d087477eea6eb Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 13 Sep 2021 11:26:48 +0200 Subject: [PATCH] [Helper] Don't tell g_utf8_strlen to ignore length. Fixes: #1459 --- source/helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/helper.c b/source/helper.c index 1c2265d0..59539ef8 100644 --- a/source/helper.c +++ b/source/helper.c @@ -183,7 +183,8 @@ static char *utf8_helper_simplify_string(const char *s) { 0, }; // Compose the string in maximally composed form. - char *str = g_malloc0((g_utf8_strlen(s, 0) * 6 + 2)); + ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char); + char *str = g_malloc0(str_size); char *striter = str; for (const char *iter = s; iter && *iter; iter = g_utf8_next_char(iter)) { gunichar uc = g_utf8_get_char(iter);