]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed another array out of bounds bug
authorTore Engvig <tore@apache.org>
Thu, 7 Jun 2001 21:02:01 +0000 (21:02 +0000)
committerTore Engvig <tore@apache.org>
Thu, 7 Jun 2001 21:02:01 +0000 (21:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194281 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/layout/hyphenation/HyphenationTree.java

index ef78c6816d3902d87d945fb1e2019b22f7442062..55b7d2e5fd8ca88105b1af734450832a88f5841e 100644 (file)
@@ -220,13 +220,13 @@ public class HyphenationTree extends TernaryTree
          char sp = word[i];
          p = root;
 
-         while( p != 0 ) {
+         while( p > 0 && p < sc.length){
             if (sc[p] == 0xFFFF) {
                if ( hstrcmp(word, i, kv.getArray(), lo[p]) == 0 ) {
                   values = getValues(eq[p]);  // data pointer is in eq[]
                   int j=index;
                   for(int k=0; k<values.length; k++) {
-                     if ( values[k] > il[j] )
+                     if ( j < il.length && values[k] > il[j] )
                         il[j] = values[k];
                      j++;
                   }
@@ -235,17 +235,19 @@ public class HyphenationTree extends TernaryTree
             }
             int d = sp - sc[p];
             if ( d == 0 ) {
-               if ( sp == 0 )
-                  break;
+                if ( sp == 0 ) {
+                    break;
+                }
                sp = word[++i];
                p = eq[p];
                q = p;
 
                // look for a pattern ending at this position by searching for
                // the null char ( splitchar == 0 )
-               while ( q != 0 ) {
-                  if ( sc[q] == 0xFFFF ) // stop at compressed branch
+               while ( q > 0 && q < sc.length ) {
+                  if ( sc[q] == 0xFFFF ) {// stop at compressed branch
                      break;
+                  }
                   if ( sc[q] == 0 ) {
                      values = getValues(eq[q]);
                      int j=index;