2006-07-26 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/GapContent.java
(getChars): Check for negative length and throw
BadLocationException.
/Roman
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.52
diff -u -1 -2 -r1.52 GapContent.java
--- javax/swing/text/GapContent.java 21 Jun 2006 09:17:09 -0000 1.52
+++ javax/swing/text/GapContent.java 26 Jul 2006 07:53:38 -0000
@@ -483,24 +483,26 @@
throws BadLocationException
{
// check arguments
int length = length();
if (where < 0)
throw new BadLocationException("the where argument may not be below zero", where);
if (where >= length)
throw new BadLocationException("the where argument cannot be greater"
+ " than the content length", where);
if ((where + len) > length)
throw new BadLocationException("len plus where cannot be greater"
+ " than the content length", len + where);
+ if (len < 0)
+ throw new BadLocationException("negative length not allowed: ", len);
// check if requested segment is contiguous
if ((where < gapStart) && ((gapStart - where) < len))
{
// requested segment is not contiguous -> copy the pieces together
char[] copy = new char[len];
int lenFirst = gapStart - where; // the length of the first segment
System.arraycopy(buffer, where, copy, 0, lenFirst);
System.arraycopy(buffer, gapEnd, copy, lenFirst, len - lenFirst);
txt.array = copy;
txt.offset = 0;
txt.count = len;
