Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: FontBox
    • Labels:
    • Flags:
      Patch

      Description

      A bug in the usage of the result of a binary search causes a crash in the calculation of kerning information. Here's the patch:

      --- a/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
      +++ b/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
      @@ -292,7 +292,7 @@ public class KerningSubtable
                   index = Arrays.binarySearch(pairs, searchRange, pairs.length, key, this);
                   if (index >= 0)
                   {
      -                return pairs[searchRange + index][2];
      +                return pairs[index][2];
                   }
                   return 0;
               }
      

      Explanation: The searchRange parameter is passed to binarySearch(), but the result of binarySearch() is relative to the start of the array, not the passed-in start. So no need to add searchRange to the result. Adding causes the indexing to go off the end of the array.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lehmi Andreas Lehmkühler
                Reporter:
                lkesteloot Lawrence Kesteloot
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: