Uploaded image for project: 'XNIO'
  1. XNIO
  2. XNIO-131

ByteString.substring method erroneously throws IndexOutOfBoundsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.1.0.Beta2
    • None
    • api
    • None
    • Hide

      Invert the sign of the index out of bounds check, i.e., the statement below
      if (this.len - offs > len) throw new IndexOutOfBoundsException();
      Should be replaced by:
      if (this.len - offs < len) throw new IndexOutOfBoundsException();

      Show
      Invert the sign of the index out of bounds check, i.e., the statement below if (this.len - offs > len) throw new IndexOutOfBoundsException(); Should be replaced by: if (this.len - offs < len) throw new IndexOutOfBoundsException();

      ByteString.substring(int offs, int len) throws IndexOutOfBoundsException if there are enough bytes to perform the substring operation.
      The correct would be throwing the exception if there are not enough bytes.
      This bug also affects ByteString.substring(int offs), because this method delegates execution to substring(int, int).

            flaviarnn Flavia Rainone
            flaviarnn Flavia Rainone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: