Index: ftxgsub.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgsub.c,v
retrieving revision 1.14
diff -u -r1.14 ftxgsub.c
--- ftxgsub.c	27 Jul 2003 02:40:31 -0000	1.14
+++ ftxgsub.c	28 Jul 2003 09:27:37 -0000
@@ -1248,16 +1248,15 @@
             break;
         }
 
+        if ( in->pos + j >= in->length )
+          break;
+
         /* don't apply a ligature lookup to glyphs with different
            ligature IDs.  Example:
 
                                                        '
                                   ^'              '    ^
              f ^ l ' -> fl ^ ' -> fl  but not  fl ^ -> fl         */
-
-        if ( first_ligID != lig_in[j] )
-          break;
-
         /* don't apply a ligature lookup to glyphs with different
            component values.  Example:
 
@@ -1265,7 +1264,7 @@
                                      ^'                '    ^
              f ^ f ' l -> ffl ^ ' -> ffl  but not  ffl ^ -> ffl   */
 
-        if ( first_comp != comp_in[j] )
+        if ( first_ligID != lig_in[j] && first_comp != comp_in[j] )
           break;
 
         if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) )
@@ -2166,6 +2165,9 @@
             break;
         }
 
+        if ( in->pos + j >= in->length )
+          break;
+
         if ( s_in[j] != sr[k].Input[i - 1] )
           break;
       }
@@ -3504,6 +3506,9 @@
             break;
         }
 
+        if ( curr_pos + j >= in->length )
+          break;
+
         if ( s_in[j] != curr_csr.Input[i - 1] )
           break;
       }
@@ -3529,6 +3534,9 @@
           else
             break;
         }
+
+        if ( curr_pos + j >= in->length )
+          break;
 
         if ( s_in[j] != curr_csr.Lookahead[i] )
           break;
