harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey A. Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-2566) [classlib][swing] j.s.text.GapContent.getChars throws NPE rather than BadLocationException
Date Mon, 11 Dec 2006 08:50:22 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-2566?page=all ]

Alexey A. Ivanov updated HARMONY-2566:
--------------------------------------

    Attachment: H2566-GapContent.patch

The fix.
Using Integer.MAX_VALUE as length parameter causes overflow in the code where parameters are
checked. I've moved offset to the other side of the inequality. It is quite safe because length
and offset are guaranteed to be positive at this point.

> [classlib][swing] j.s.text.GapContent.getChars throws NPE rather than BadLocationException
> ------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2566
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2566
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Alexey A. Ivanov
>         Attachments: H2566-GapContent.patch, H2566-GapContentTest.patch
>
>
> Consider the following code:
> import javax.swing.text.GapContent;
> public class Test {
>     public static void main(String[] args) {
>         GapContent content = new GapContent();
>         try {
>             content.getChars(1, Integer.MAX_VALUE, null);
>         } catch (Exception e) {
>             e.printStackTrace();
>         } 
>     }
> }
> ------------ end of code ------------
> Running this application on Harmony produces the output:
> java.lang.NullPointerException
> 	at javax.swing.text.GapContent.getChars(GapContent.java:152)
> 	at Test.main(Test.java:7)
> ------------ end of Harmony output ------------
> Whereas RI throws BadLocationException:
> javax.swing.text.BadLocationException: Invalid location
> 	at javax.swing.text.GapContent.getChars(GapContent.java:169)
> 	at Test.main(Test.java:7)
> ------------ end of RI output ------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message