From 275fc445231e24385bd5ccb2382c5e84750d2e1f Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 11 Oct 2008 20:03:23 +0200 Subject: [PATCH] Avoid crash when resizing window Sanity check input to gui_macvim_draw_string(); it can happen that 'len' is non-zero even though first byte of 's' is NUL (test case with file containing Chinese characters). --- src/MacVim/gui_macvim.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 6fd9804838..a54d35e0eb 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -323,8 +323,10 @@ // wide and vice versa. for (i = 0; i < len; i += cl) { c = utf_ptr2char(s + i); - cl = utf_ptr2len(s + i); cn = utf_char2cells(c); + cl = utf_ptr2len(s + i); + if (0 == cl) + len = i; // len must be wrong (shouldn't happen) if (!utf_iscomposing(c)) { if ((cn > 1 && !wide) || (cn <= 1 && wide)) {