From 425cc014ac9191debe8c01dc360685486bba0ff1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 23 Aug 2011 11:38:29 +0300 Subject: [PATCH] Fix crashes with completion and composed characters. src/dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos instead of CHAR_TO_BYTE. Fixes a crash when a completion candidate is selected by the mouse, and that candidate has a composed character under the mouse. --- src/ChangeLog | 5 +++++ src/dispnew.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index ffb8dd76366..d4f654a1028 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-08-23 Eli Zaretskii + * dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos + instead of CHAR_TO_BYTE. Fixes a crash when a completion + candidate is selected by the mouse, and that candidate has a + composed character under the mouse. + * xdisp.c (x_produce_glyphs): Set it->nglyphs to 1. Fixes pixel coordinates reported by pos-visible-in-window-p for a composed character in column zero. diff --git a/src/dispnew.c b/src/dispnew.c index fadfbb26603..e2bcf5d7090 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5307,7 +5307,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p if (STRINGP (it.string)) BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); else - BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos)); + BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), + CHARPOS (pos->pos)); } #ifdef HAVE_WINDOW_SYSTEM -- 2.39.2