Don't generate mouse input records on an incomplete mouse escape sequence

This commit is contained in:
Ryan Prichard 2016-01-14 17:02:59 -06:00
parent 79c9859805
commit 48e01facf4
2 changed files with 12 additions and 3 deletions

View File

@ -1,3 +1,8 @@
# Next version
* Fix a bug that could have generated spurious mouse input records when an
incomplete mouse escape sequence was seen.
# Version 0.2.1 (2015-12-19) # Version 0.2.1 (2015-12-19)
* The main project source was moved into a `src` directory for better code * The main project source was moved into a `src` directory for better code

View File

@ -167,6 +167,10 @@ static int matchMouse1015(const char *input, int inputSize, MouseRecord &out)
return pch - input + 1; return pch - input + 1;
} }
// Match a mouse input escape sequence of any kind.
// 0 no match
// >0 match, returns length of match
// -1 incomplete match
static int matchMouseRecord(const char *input, int inputSize, MouseRecord &out) static int matchMouseRecord(const char *input, int inputSize, MouseRecord &out)
{ {
memset(&out, 0, sizeof(out)); memset(&out, 0, sizeof(out));
@ -379,9 +383,9 @@ int ConsoleInput::scanMouseInput(std::vector<INPUT_RECORD> &records,
int inputSize) int inputSize)
{ {
MouseRecord record; MouseRecord record;
int len = matchMouseRecord(input, inputSize, record); const int len = matchMouseRecord(input, inputSize, record);
if (len == 0) { if (len <= 0) {
return 0; return len;
} }
if (isTracingEnabled()) { if (isTracingEnabled()) {