Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-406

[RAM] resize throws ArrayOOBE when shrinking in size.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None

    Description

      Im targetting 2.0 as it is the official download.

      The fix is quite simple.

      FILE: RamFileObject

      ORIGINAL
      void resize(int newSize)

      { int size = this.size(); byte[] newBuf = new byte[newSize]; System.arraycopy(this.buffer, 0, newBuf, 0, size); this.buffer = newBuf; updateLastModified(); }

      // when shrinking size > newSize thus an AOOBE will be thrown.

      FIXED
      void resize(final int newSize)

      { final int size = this.size(); final byte[] newBuf = new byte[newSize]; // HACK fixed error which prevented resizing to a small buffer. System.arraycopy(this.buffer, 0, newBuf, 0, Math.min(newSize, size)); this.buffer = newBuf; this.updateLastModified(); }

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            mp1 Miroslav Pokorny
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 5m
                5m
                Remaining:
                Remaining Estimate - 5m
                5m
                Logged:
                Time Spent - Not Specified
                Not Specified