Fix the out of bounds of array
This commit is contained in:
committed by
Raphael Coeffic
parent
ba81224806
commit
e487273ce9
+8
-6
@@ -209,13 +209,15 @@ void TextEdit::onEvent(event_t event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_PGDN):
|
case EVT_KEY_BREAK(KEY_PGDN):
|
||||||
memmove(&value[cursorPos], &value[cursorPos + 1], length - cursorPos - 1);
|
if (cursorPos < length) {
|
||||||
value[length - 1] = '\0';
|
memmove(&value[cursorPos], &value[cursorPos + 1], length - cursorPos - 1);
|
||||||
changed = true;
|
value[length - 1] = '\0';
|
||||||
if (cursorPos > 0 && value[cursorPos] == '\0') {
|
changed = true;
|
||||||
cursorPos = cursorPos - 1;
|
if (cursorPos > 0 && value[cursorPos] == '\0') {
|
||||||
|
cursorPos = cursorPos - 1;
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
invalidate();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user