On Friday 30 January 2009 15:43:34 nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2009-01-30 15:43:34 +0000 (Fri, 30 Jan 2009)
> New Revision: 25398
>
> Modified:
> trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
> Log:
> doh2!
>
> Modified: trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
> ===================================================================
> --- trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
2009-01-30 15:21:49 UTC (rev 25397)
> +++ trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
2009-01-30 15:43:34 UTC (rev 25398)
> @@ -35,7 +35,7 @@
> int ctr = 0;
> mark(maxLength + 2); // in case we have both a \r and a \n
> while(true) {
> - int x = read(buf, ctr, Math.min(1, buf.length - ctr));
> + int x = read(buf, ctr, Math.max(1, buf.length - ctr));
This is bad. If it does anything (which I doubt), it will generate
ArrayIndexOutOfBounds'es.
If this code is busy looping then there must be another reason for it. If
buf.length == ctr, then the buffer should be extended automatically, unless
buf.length == maxLength, in which case we should throw a TooLongException.
This won't happen if we read 0 bytes, but in that case we would have thrown
on the previous iteration.
> if(x == -1) {
> if(ctr == 0)
> return null;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20090224/e4cc6a47/attachment.pgp>