On Fri, 14 Oct 2022 09:16:27 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>> DefaultListSelectionModel.removeIndexInterva accepts `int` value which 
>> allows it to take in Integer.MAX_VALUE theoratically but it does calculation 
>> with that value which can results in IOOBE.
>> Fix is to make sure the calculation stays within bounds.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   javadoc update

There exists at least one other problem because of integer overflow in 
`insertIndexInterval`.

This code

        selectionModel.setSelectionInterval(Integer.MAX_VALUE - 1, 
Integer.MAX_VALUE);
        selectionModel.insertIndexInterval(Integer.MAX_VALUE - 1, 
Integer.MAX_VALUE, true);

throws

Exception in thread "main" java.lang.IndexOutOfBoundsException: bitIndex < 0: -2
        at java.base/java.util.BitSet.get(BitSet.java:626)
        at 
java.desktop/javax.swing.DefaultListSelectionModel.set(DefaultListSelectionModel.java:311)
        at 
java.desktop/javax.swing.DefaultListSelectionModel.setState(DefaultListSelectionModel.java:629)
        at 
java.desktop/javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:657)
        at SelectionModelTest.main(SelectionModelTest.java)


Would you like to include it as part of this fix? Shall I submit a new bug for 
this?

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

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

Reply via email to