Index: pango/opentype/ftxgpos.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgpos.c,v
retrieving revision 1.26
diff -u -p -r1.26 ftxgpos.c
--- pango/opentype/ftxgpos.c	22 Sep 2004 18:14:55 -0000	1.26
+++ pango/opentype/ftxgpos.c	22 Mar 2005 04:36:17 -0000
@@ -5877,7 +5877,7 @@
                                     FT_UShort         context_length,
                                     int               nesting_level )
   {
-    FT_Error         error = TT_Err_Ok;
+    FT_Error         error = TTO_Err_Not_Covered;
     FT_UShort        i, flags;
     TTO_GPOSHeader*  gpos = gpi->gpos;
     TTO_Lookup*      lo;
@@ -6055,7 +6055,7 @@
     FT_UInt*     properties;
     FT_UShort*   index;
 
-    /* Each feature can only be added once once */
+    /* Each feature can only be added once */
     
     if ( !gpos ||
          feature_index >= gpos->FeatureList.FeatureCount ||
@@ -6159,7 +6159,13 @@
 
       for ( j = 0; j < feature.LookupListCount; j++ )
       {
-	error = Do_String_Lookup( &gpi, feature.LookupListIndex[j], buffer );
+	FT_UShort lookup_index = feature.LookupListIndex[j];
+
+	/* Skip nonexistant lookups */
+        if (lookup_index >= gpos->LookupList.LookupCount)
+	 continue;
+
+	error = Do_String_Lookup( &gpi, lookup_index, buffer );
 	if ( error )
 	{
 	  if ( error != TTO_Err_Not_Covered )
Index: pango/opentype/ftxgsub.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgsub.c,v
retrieving revision 1.27
diff -u -p -r1.27 ftxgsub.c
--- pango/opentype/ftxgsub.c	22 Sep 2004 18:14:55 -0000	1.27
+++ pango/opentype/ftxgsub.c	22 Mar 2005 04:36:18 -0000
@@ -3945,7 +3945,7 @@
                                     FT_UShort         context_length,
                                     int               nesting_level )
   {
-    FT_Error     error = TT_Err_Ok;
+    FT_Error     error = TTO_Err_Not_Covered;
     FT_UShort    i, flags;
     TTO_Lookup*  lo;
 
@@ -4063,7 +4063,7 @@
     FT_UInt*     properties;
     FT_UShort*   index;
 
-    /* Each feature can only be added once once */
+    /* Each feature can only be added once */
     
     if ( !gsub ||
          feature_index >= gsub->FeatureList.FeatureCount ||
@@ -4140,7 +4140,13 @@
 
       for ( j = 0; j < feature.LookupListCount; j++ )
       {
-        error = Do_String_Lookup( gsub, feature.LookupListIndex[j], buffer );
+	FT_UShort lookup_index = feature.LookupListIndex[j];
+
+	/* Skip nonexistant lookups */
+        if (lookup_index >= gsub->LookupList.LookupCount)
+	 continue;
+
+        error = Do_String_Lookup( gsub, lookup_index, buffer );
 	if ( error )
 	{
 	  if ( error != TTO_Err_Not_Covered )
