From: Eli Zaretskii Date: Tue, 30 Mar 2010 16:29:02 +0000 (+0300) Subject: Fix a crash of I-search in a bidi-reordered buffer. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~628 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bd924a5d6cea9a17c4c46f6ce3ecdef875dad69f;p=emacs.git Fix a crash of I-search in a bidi-reordered buffer. bidi.c (bidi_cache_iterator_state): Invalidate the cache if we are outside the range of cached character positions. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7809565de87..44c55252b62 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-30 Eli Zaretskii + + * bidi.c (bidi_cache_iterator_state): Invalidate the cache if we + are outside the range of cached character positions. + 2010-03-30 Juanma Barranquero * makefile.w32-in ($(BLD)/bidi.$(O)): Add dependency on w32gui.h. diff --git a/src/bidi.c b/src/bidi.c index d5e28cd2d8a..ea47cd33fec 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -671,10 +671,16 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) /* Don't overrun the cache limit. */ if (idx > sizeof (bidi_cache) / sizeof (bidi_cache[0]) - 1) abort (); - /* Don't violate cache integrity: character positions should - correspond to cache positions 1:1. */ - if (idx > 0 && bidi_it->charpos != bidi_cache[idx - 1].charpos + 1) - abort (); + /* Character positions should correspond to cache positions 1:1. + If we are outside the range of cached positions, the cache is + useless and must be reset. */ + if (idx > 0 && + (bidi_it->charpos > bidi_cache[idx - 1].charpos + 1 + || bidi_it->charpos < bidi_cache[0].charpos)) + { + bidi_cache_reset (); + idx = 0; + } bidi_copy_it (&bidi_cache[idx], bidi_it); if (!resolved) bidi_cache[idx].resolved_level = -1;