Fix ByteBufferInputStream buffer overflow, close #1281