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

[RAM] resize throws ArrayOOBE when shrinking in size.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Labels:
      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

            • Assignee:
              ggregory Gary Gregory
              Reporter:
              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