Terminal Lockup
Dino Klein
zagzag-lists at speakeasy.net
Mon Nov 28 05:40:08 MET 2005
I got a fix here for the terminal lock up.
The decoding process will choke on any malformed input, and stay
that way, since the erroneous state is never cleared in
com.mindbright.terminal.filter.Filter.intConvertFrom(); in fact,
the two decodeFrom() methods that call it will continually resize
the input buffer to accommodate new data, until the JVM runs out
of memory.
The patch below will change the decoder's default behavior to
substitute a malformed sequence, so that processing can go on.
I've gave this a try only with a UTF-8 encoding.
Also, perhaps the encoder should be adjusted in a similar fashion?
If it gets fed a malformed sequence, then it will choke as well.
--- mindterm_3.0-orig/com/mindbright/terminal/filter/Filter.java 2005-11-03 17:13:57.000000000 -0500
+++ mindterm_3.0/com/mindbright/terminal/filter/Filter.java 2005-11-27 23:10:34.000000000 -0500
@@ -24,6 +24,7 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
@@ -44,6 +45,8 @@
Charset charset = Charset.forName(name);
encoder = charset.newEncoder();
decoder = charset.newDecoder();
+ decoder.onMalformedInput(CodingErrorAction.REPLACE);
+ decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
decode_in = ByteBuffer.allocate(16);
decode_out = CharBuffer.allocate(16);
More information about the Mindterm-users
mailing list