#504 fix potential NPE in StreamEncoder (char-array can be null)

This commit is contained in:
Andreas Gudian 2015-03-17 13:52:12 +01:00
parent 0674a8780b
commit fb8a6e3ae0

View File

@ -143,22 +143,24 @@ class IndentationCorrectingWriter extends Writer {
} }
private void flush(StateContext context) throws IOException { private void flush(StateContext context) throws IOException {
context.writer.write( if ( null != context.characters && context.currentIndex - context.lastStateChange > 0 ) {
context.characters, context.writer.write(
context.lastStateChange, context.characters,
context.currentIndex - context.lastStateChange context.lastStateChange,
); context.currentIndex - context.lastStateChange
if ( DEBUG ) {
System.out.print(
new String(
java.util.Arrays.copyOfRange(
context.characters,
context.lastStateChange,
context.currentIndex
)
)
); );
if ( DEBUG ) {
System.out.print(
new String(
java.util.Arrays.copyOfRange(
context.characters,
context.lastStateChange,
context.currentIndex
)
)
);
}
} }
} }
}, },