This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] java.io.ByteArrayOutputStream


While testing Jetty I noticed that a ByteArrayOutputStream prematurely
resizes `buf' due to an off-by-one error.  This fixes a test I posted
to mauve-patches.

Jeff

2003-10-30  Jeff Sturm  <jsturm@one-point.com>

	* java/io/ByteArrayOutputStream.java (resize):
	Fix off-by-one error.

Index: java/io/ByteArrayOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/ByteArrayOutputStream.java,v
retrieving revision 1.11
diff -u -p -r1.11 ByteArrayOutputStream.java
--- java/io/ByteArrayOutputStream.java	23 Mar 2003 19:11:18 -0000	1.11
+++ java/io/ByteArrayOutputStream.java	31 Oct 2003 05:14:48 -0000
@@ -198,7 +198,7 @@ public class ByteArrayOutputStream exten
   // Resize buffer to accommodate new bytes.
   private void resize (int add)
   {
-    if (count + add >= buf.length)
+    if (count + add > buf.length)
       {
 	int newlen = buf.length * 2;
 	if (count + add > newlen)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]