diff options
author | HampusM <hampus@hampusmat.com> | 2022-07-02 15:08:57 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-07-02 15:08:57 +0200 |
commit | 33f5395f99cf5f93d2e782933129ed5fc2fde091 (patch) | |
tree | 75a6fdee2fd89649dfc63ac1b005c9def4f60fe5 /src/game/game.cpp | |
parent | 578cf43e9c8384aab463aa2a33c5be00e46dc999 (diff) |
This will prevent heap-buffer-overflows from occuring when opening RLE files with pattern sizes exceeding the current terminal size
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 05b02fd..9835fc5 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -613,12 +613,19 @@ void Game::_open_rle_file(CommandInfo::Options options) noexcept return; } + auto scene_matrix = _scene->get_matrix(); + + if (rle_matrix->get_size() > scene_matrix->get_size()) + { + _show_command_error("Error: The pattern in the RLE file is too large for the " + "current terminal size"); + return; + } + _return_to_normal_mode(); const auto previous_pos = _cursor_controller->where(); - auto scene_matrix = _scene->get_matrix(); - for (auto row : *rle_matrix) { for (auto &col : row) |