diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2023-11-30 11:05:33 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 11:05:33 -0600 |
commit | 7feed6ccb7ddfa3bc789158a3b7874d12652e9c5 (patch) | |
tree | 5e3af5e0d53a5eaff806e7671d5afe967008ec35 | |
parent | f5573fba3d460ddf479826b7404e568cc825ed57 (diff) | |
download | rneovim-7feed6ccb7ddfa3bc789158a3b7874d12652e9c5.tar.gz rneovim-7feed6ccb7ddfa3bc789158a3b7874d12652e9c5.tar.bz2 rneovim-7feed6ccb7ddfa3bc789158a3b7874d12652e9c5.zip |
refactor: explicitly abort on OOM condition (#26330)
assert() would not abort in release builds, meaning an OOM condition
would be undetected.
-rw-r--r-- | src/nvim/tui/input.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 4ebd2acc1d..b9e2d2c9ee 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -700,12 +700,12 @@ static void handle_raw_buffer(TermInput *input, bool force) if (size > termkey_get_buffer_remaining(input->tk)) { // We are processing a very long escape sequence. Increase termkey's // internal buffer size. We don't handle out of memory situations so - // assert the result + // abort if it fails const size_t delta = size - termkey_get_buffer_remaining(input->tk); const size_t bufsize = termkey_get_buffer_size(input->tk); - const bool success = termkey_set_buffer_size(input->tk, MAX(bufsize + delta, bufsize * 2)); - assert(success); - (void)success; + if (!termkey_set_buffer_size(input->tk, MAX(bufsize + delta, bufsize * 2))) { + abort(); + } } size_t consumed = termkey_push_bytes(input->tk, ptr, size); @@ -730,9 +730,9 @@ static void handle_raw_buffer(TermInput *input, bool force) if (tk_count < INPUT_BUFFER_SIZE && tk_size > INPUT_BUFFER_SIZE) { // If the termkey buffer was resized to handle a large input sequence then // shrink it back down to its original size. - const bool success = termkey_set_buffer_size(input->tk, INPUT_BUFFER_SIZE); - assert(success); - (void)success; + if (!termkey_set_buffer_size(input->tk, INPUT_BUFFER_SIZE)) { + abort(); + } } } |