summarylogtreecommitdiffstats
path: root/sidebar-delimnullwide.patch
blob: 11d2ced5a0c08a96a78cee7efdce292c7cf7d6c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From: Evgeni Golov <sargentd@die-welt.net>
Date: Wed, 5 Mar 2014 17:46:07 +0100
Subject: sidebar-delimnullwide

SidebarDelim can be NULL and strlen(NULL) is a bad idea, as it will segfault.
Wrap it with NONULL().

While at it, change strlen to mbstowcs for better utf8 support.

Closes: #696145, #663883

Gbp-Pq: Topic mutt-patched
---
 sidebar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sidebar.c b/sidebar.c
index 51a25ca..c3ea338 100644
--- a/sidebar.c
+++ b/sidebar.c
@@ -88,7 +88,7 @@ char *make_sidebar_entry(char *box, int size, int new, int flagged)
     int box_len, box_bytes;
     int int_len;
     int right_offset = 0;
-    int delim_len = strlen(SidebarDelim);
+    int delim_len = mbstowcs(NULL, NONULL(SidebarDelim), 0);
     static char *entry;
 
     right_width = left_width = 0;
@@ -178,7 +178,7 @@ int draw_sidebar(int menu) {
 #ifndef USE_SLANG_CURSES
         attr_t attrs;
 #endif
-        short delim_len = strlen(SidebarDelim);
+        short delim_len = mbstowcs(NULL, NONULL(SidebarDelim), 0);
         short color_pair;
 
         static bool initialized = false;