diff options
| author | dam <dam@gudinoff> | 2023-12-08 03:18:32 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-12-08 03:18:32 +0000 |
| commit | 1fe3a96afaa781c2b54f89cbeaaca8c101f2452b (patch) | |
| tree | e6a7abf017bc48c4e81b8be2008f02041749ff4b | |
| parent | f0aab177c96c6bda25927f4b748c39f2847df47a (diff) | |
| download | task-time-tracker-1fe3a96afaa781c2b54f89cbeaaca8c101f2452b.tar.zst task-time-tracker-1fe3a96afaa781c2b54f89cbeaaca8c101f2452b.zip | |
Fix potential out-of-bounds bug in get_terminal_size and get_cursor_size.
| -rw-r--r-- | TUI/module.jai | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/TUI/module.jai b/TUI/module.jai index 5157ba2..c8a5512 100644 --- a/TUI/module.jai +++ b/TUI/module.jai @@ -335,11 +335,12 @@ get_terminal_size :: () -> rows: int, columns: int { } // Discard tail noise. - while input.count >= 2 && input[input.count-1] != FORMAT[FORMAT.count-1] { + while input.count >= 3 && input[input.count-1] != FORMAT[FORMAT.count-1] { input.count -= 1; } - assert(input[0] == FORMAT[0] && input[1] == FORMAT[1] && input[2] == FORMAT[2] && input[input.count-1] == FORMAT[FORMAT.count-1], + assert(input.count >= 3 && + input[0] == FORMAT[0] && input[1] == FORMAT[1] && input[2] == FORMAT[2] && input[input.count-1] == FORMAT[FORMAT.count-1], "Query window size in chars returned invalid response."); parts := split(input, ";"); @@ -379,7 +380,8 @@ get_cursor_position :: () -> row: int, column: int { input.count -= 1; } - assert(input[0] == FORMAT[0] && input[1] == FORMAT[1] && input[input.count-1] == FORMAT[FORMAT.count-1], + assert(input.count >= 2 && + input[0] == FORMAT[0] && input[1] == FORMAT[1] && input[input.count-1] == FORMAT[FORMAT.count-1], "Query cursor position returned invalid response."); |
