changeset 107884:8b1a353e3aab

Fix a crash when an NSM character is inserted at BEGV. bidi.c (bidi_init_it): Fix initialization of bidi_it->prev. (bidi_resolve_weak): Don't use prev.type_after_w1 if it is NEUTRAL_B or UNKNOWN_BT.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 17 Apr 2010 16:34:23 +0300
parents d177bcced744
children 1da056389889
files src/ChangeLog src/bidi.c
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Apr 16 21:52:12 2010 -0500
+++ b/src/ChangeLog	Sat Apr 17 16:34:23 2010 +0300
@@ -1,3 +1,11 @@
+2010-04-17  Eli Zaretskii  <eliz@gnu.org>
+
+	Fix a crash when an NSM character is inserted at BEGV.
+
+	* bidi.c (bidi_init_it): Fix initialization of bidi_it->prev.
+	(bidi_resolve_weak): Don't use prev.type_after_w1 if it is
+	NEUTRAL_B or UNKNOWN_BT.
+
 2010-04-16  Eli Zaretskii  <eliz@gnu.org>
 
 	* xdisp.c (set_cursor_from_row): Don't consider possibility of
--- a/src/bidi.c	Fri Apr 16 21:52:12 2010 -0500
+++ b/src/bidi.c	Sat Apr 17 16:34:23 2010 +0300
@@ -976,10 +976,11 @@
   bidi_it->new_paragraph = 1;
   bidi_it->separator_limit = -1;
   bidi_it->type = NEUTRAL_B;
-  bidi_it->type_after_w1 = UNKNOWN_BT;
-  bidi_it->orig_type = UNKNOWN_BT;
+  bidi_it->type_after_w1 = NEUTRAL_B;
+  bidi_it->orig_type = NEUTRAL_B;
   bidi_it->prev_was_pdf = 0;
-  bidi_it->prev.type = bidi_it->prev.type_after_w1 = UNKNOWN_BT;
+  bidi_it->prev.type = bidi_it->prev.type_after_w1 =
+    bidi_it->prev.orig_type = UNKNOWN_BT;
   bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 =
     bidi_it->last_strong.orig_type = UNKNOWN_BT;
   bidi_it->next_for_neutral.charpos = -1;
@@ -1353,7 +1354,9 @@
 	     current level run, and thus not relevant to this NSM.
 	     This is why NSM gets the type_after_w1 of the previous
 	     character.  */
-	  if (bidi_it->prev.type != UNKNOWN_BT)
+	  if (bidi_it->prev.type_after_w1 != UNKNOWN_BT
+	      /* if type_after_w1 is NEUTRAL_B, this NSM is at sor */
+	      && bidi_it->prev.type_after_w1 != NEUTRAL_B)
 	    type = bidi_it->prev.type_after_w1;
 	  else if (bidi_it->sor == R2L)
 	    type = STRONG_R;