RFR: 8291792: DefaultStyledDocument.setCharacterAttribute accepts negative length

Tejesh R tr at openjdk.org
Wed Aug 17 06:16:00 UTC 2022


The Document for _DefaultStyledDocument.setCharacterAttribute_ states that the range of length accepted is `length - the length >= 0`, whereas in code the length check is done only for `length==0`. Meaning the control just returns if the `length` is 0. Since length is  _int_ type and there is a possibility of negative length being set through the method, the code doesn't actually handles the negative length case. Hence to handle negative length, negative length check has been added along with 0 check. Its safe to check and return the control for `negative` length input. Test case to check the same is added.

-------------

Commit messages:
 - Removed white spaces
 - Fix : negative length check added and corresponding test added
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge branch 'master' of github.com:TejeshR13/jdk
 - Merge branch 'openjdk:master' into master
 - Merge remote-tracking branch 'upstream/master'
 - ... and 3 more: https://git.openjdk.org/jdk/compare/77398430...2faa3400

Changes: https://git.openjdk.org/jdk/pull/9830/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9830&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8291792
  Stats: 86 lines in 2 files changed: 85 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/9830.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9830/head:pull/9830

PR: https://git.openjdk.org/jdk/pull/9830



More information about the client-libs-dev mailing list