Checks for buffer out of bounds before writing to the stream. Fixes #636
This commit is contained in:
@@ -34,10 +34,10 @@ public final class RedisOutputStream extends FilterOutputStream {
|
||||
}
|
||||
|
||||
public void write(final byte b) throws IOException {
|
||||
buf[count++] = b;
|
||||
if (count == buf.length) {
|
||||
flushBuffer();
|
||||
}
|
||||
buf[count++] = b;
|
||||
}
|
||||
|
||||
public void write(final byte[] b) throws IOException {
|
||||
@@ -63,10 +63,10 @@ public final class RedisOutputStream extends FilterOutputStream {
|
||||
final int size = in.length();
|
||||
|
||||
for (int i = 0; i != size; ++i) {
|
||||
buf[count++] = (byte) in.charAt(i);
|
||||
if (count == buf.length) {
|
||||
flushBuffer();
|
||||
}
|
||||
buf[count++] = (byte) in.charAt(i);
|
||||
}
|
||||
|
||||
writeCrLf();
|
||||
@@ -111,19 +111,19 @@ public final class RedisOutputStream extends FilterOutputStream {
|
||||
char c = str.charAt(i);
|
||||
if (!(c < 0x80))
|
||||
break;
|
||||
buf[count++] = (byte) c;
|
||||
if (count == buf.length) {
|
||||
flushBuffer();
|
||||
}
|
||||
buf[count++] = (byte) c;
|
||||
}
|
||||
|
||||
for (; i < strLen; i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c < 0x80) {
|
||||
buf[count++] = (byte) c;
|
||||
if (count == buf.length) {
|
||||
flushBuffer();
|
||||
}
|
||||
buf[count++] = (byte) c;
|
||||
} else if (c < 0x800) {
|
||||
if (2 >= buf.length - count) {
|
||||
flushBuffer();
|
||||
|
||||
Reference in New Issue
Block a user