Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8001750

CharsetDecoder.replacement should not be changeable except via replaceWith method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • core-libs

    Description


      CharsetDecoder has a number of issues that need to be fixed:

      1. The constructor that takes a replacement stores a reference to the byte[] and so it may be changed without going through the replaceWith method. In addition the constructor doesn't check that the replacement characters are legal.

      2. The replacement method hands out a reference to the internal byte[] array, leading to the same issue as 1.

      3. replaceWith has the same issue as the constructor, it stores a reference to the byte array rather than taking a copy.

      Although the above issues need to be fixed they aren't actually an issue for the single byte charsets because the implementation takes a copy of the replacement byte. So it's mostly only an issue for double byte charsets.


      Attachments

        Activity

          People

            sherman Xueming Shen
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: