From f42e10ab1d5106d48533e95088461cd69a7c8d2c Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Fri, 28 Jan 2011 21:37:53 +0000 Subject: [PATCH] Ticket #2484 (segfault after getting previous char) fixed segfault after getting the previous char in utf8, if previous char's are: 0xB1, 0xB3, 0xB6, 0xBF, 0xBC. Signed-off-by: Ilia Maslakov --- src/editor/edit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/editor/edit.c b/src/editor/edit.c index 9f083afcb..d8d339366 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -1872,7 +1872,13 @@ edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width) if (str != buf) str = g_utf8_find_prev_char (buf, str); - res = g_utf8_get_char_validated (str, -1); + if (res < 0 || str == NULL) + { + *char_width = 0; + return 0; + } + else + res = g_utf8_get_char_validated (str, -1); if (res < 0) {