Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-125

Incorrect size calculation in InstructionFinder

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 6.0
    • Component/s: Main
    • Labels:
      None

      Description

      In InstructionFinder class, line 229 size of the matched pattern is calculated as

      int lenExpr = (endExpr - startExpr) + 1;

      this is incorrect as endExpr is always given as one past the last index and this function causes the iterator being returned to always have one more instruction then requested. Also this can cause a crash if the pattern requested is at the end of a search list as index goes out of bounds.

      suggested fix (I have it working locally with no problems):

      int lenExpr = (endExpr - startExpr);

        Attachments

          Activity

            People

            • Assignee:
              issues@commons.apache.org Apache Commons Developers
              Reporter:
              nebojsa.grujic@gmail.com Nebojsa Grujic
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: