Fix possible NPE in MonitoringGuacamoleReader read() and readInstruction().

This commit is contained in:
Michael Jumper
2014-03-06 10:42:25 -08:00
parent 4851ba8b5c
commit e4f67e5aff

View File

@@ -66,13 +66,23 @@ public class MonitoringGuacamoleReader implements GuacamoleReader {
@Override
public char[] read() throws GuacamoleException {
return readInstruction().toString().toCharArray();
// Read single instruction, handle end-of-stream
GuacamoleInstruction instruction = readInstruction();
if (instruction == null)
return null;
return instruction.toString().toCharArray();
}
@Override
public GuacamoleInstruction readInstruction() throws GuacamoleException {
// Read single instruction, handle end-of-stream
GuacamoleInstruction instruction = reader.readInstruction();
if (instruction == null)
return null;
// If clipboard changed, notify listeners
if (instruction.getOpcode().equals("clipboard")) {