Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-302

ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: Streams/Writers
    • Labels:
      None
    • Environment:

      Win7 64bit, Java 6 32bit

      Description

      Resetting the BOMInputStream doesn't reset the fbLength member variable. This causes fbLength to grow bigger than the firstBytes array (when the file doesn't contain a BOM), which leads to an ArrayIndexOutOfBoundsException in the readFirstBytes method.

      The attached test case reveals the problem.

        Attachments

        1. Test.java
          2 kB
          Jan Steuerwald
        2. testfileBOM.xml
          6 kB
          Jan Steuerwald
        3. testfileNoBOM.xml
          6 kB
          Jan Steuerwald
        4. IO-302.patch
          2 kB
          Marcos Vinícius da Silva

          Activity

            People

            • Assignee:
              garydgregory Gary Gregory
              Reporter:
              jsteuerwald Jan Steuerwald
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: