Welcome to the bulix.org / pastebin. Please don't use this pastebin for illegal purposes, defamation or kitten-squashing.
This pastebin is written using PHP and MySQL and relies on Alex Gorbatchev's syntax hhighlighter (JavaScript based). To avoid spam, you will be required to complete a small mathematical challenge when adding a new paste.
Index: src/freenet/support/io/LineReadingInputStream.java
===================================================================
--- src/freenet/support/io/LineReadingInputStream.java (revision 21973)
+++ src/freenet/support/io/LineReadingInputStream.java (working copy)
@@ -13,8 +13,8 @@
*/
public class LineReadingInputStream extends FilterInputStream implements LineReader {
- public LineReadingInputStream(InputStream in) {
- super(in);
+ public LineReadingInputStream(InputStream in2) {
+ super(in2);
}
/**
@@ -36,7 +36,8 @@
mark((maxLength+1)*2); // Might be more than maxLengh if we use utf8
while(true) {
int x = read(buf, ctr, buf.length - ctr);
- if(x == -1) {
+ if(x == 0) continue;
+ else if(x == -1) {
if(ctr == 0)
return null;
return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1");
@@ -41,8 +42,9 @@
return null;
return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1");
}
- // REDFLAG this is definitely safe with the above charsets, it may not be safe with some wierd ones.
- for(; ctr < buf.length; ctr++) {
+ // REDFLAG this is definitely safe with the above charsets, it may not be safe with some wierd ones.
+ int end = ctr+x;
+ for(; ctr < end; ctr++) {
if(buf[ctr] == '\n') {
String toReturn = "";
if(ctr != 0) {
@@ -58,7 +60,7 @@
}
if(x > 0) {
byte[] newBuf = new byte[Math.min(buf.length * 2, maxLength)];
- System.arraycopy(buf, 0, newBuf, 0, buf.length);
+ System.arraycopy(buf, 0, newBuf, 0, ctr);
buf = newBuf;
}
}
Powered by the Bulix.org Code Pastebin, by Maxime Petazzoni. View pastebin statistics.