Index: trunk/modules/text/src/main/java/java/text/AttributedString.java =================================================================== --- trunk/modules/text/src/main/java/java/text/AttributedString.java (revision 438744) +++ trunk/modules/text/src/main/java/java/text/AttributedString.java (working copy) @@ -399,8 +399,11 @@ } public AttributedString(AttributedCharacterIterator iterator) { + if (iterator.getBeginIndex() > iterator.getEndIndex()) { + throw new IllegalArgumentException("Invalid substring range"); + } StringBuffer buffer = new StringBuffer(); - while (iterator.current() != CharacterIterator.DONE) { + for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { buffer.append(iterator.current()); iterator.next(); } @@ -406,6 +409,9 @@ } text = buffer.toString(); Set attributes = iterator.getAllAttributeKeys(); + if (attributes == null) { + return; + } attributeMap = new HashMap>((attributes.size() * 4 / 3) + 1); Iterator it = attributes.iterator();