Allocate (size * MB_LEN_MAX) to account for a multibyte string, and also
add 1 for the null-termination coming from fribidi_unicode_to_charset.

fribidi_unicode_to_charset() null-terminates its output string:
https://github.com/fribidi/fribidi/blob/master/lib/fribidi-char-sets.h#L65

This change resolves the SIGABRT described here:

  https://lists.gnu.org/archive/html/bug-mailutils/2026-07/msg00004.html

which can be reproduced by running frm in a terminal that is exactly 70
characters wide.
---
 frm/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/frm/common.c b/frm/common.c
index e2526f283..541071677 100644
--- a/frm/common.c
+++ b/frm/common.c
@@ -111,7 +111,7 @@ alloc_logical (size_t size)
 {
   logical = mu_alloc (size * sizeof (logical[0]));
   logical_size = size;
-  outstring = mu_alloc (size);
+  outstring = mu_alloc (size * MB_LEN_MAX + 1);
 }
 
 void
-- 
2.53.0


Reply via email to