Mercurial > vim
diff src/libvterm/src/state.c @ 16429:a1229400434a v8.1.1219
patch 8.1.1219: not checking for NULL return from alloc()
commit https://github.com/vim/vim/commit/6ee9658774942f7448af700fc04df0335796a3db
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 27 22:06:37 2019 +0200
patch 8.1.1219: not checking for NULL return from alloc()
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes https://github.com/vim/vim/issues/4303, closes https://github.com/vim/vim/issues/4174)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Apr 2019 22:15:05 +0200 |
parents | c1698187c482 |
children | d1357b505d78 |
line wrap: on
line diff
--- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -253,6 +253,8 @@ static int on_text(const char bytes[], s // We'll have at most len codepoints, plus one from a previous incomplete // sequence. codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t)); + if (codepoints == NULL) + return 0; encoding = state->gsingle_set ? &state->encoding[state->gsingle_set] : @@ -330,6 +332,8 @@ static int on_text(const char bytes[], s break; chars = vterm_allocator_malloc(state->vt, (glyph_ends - glyph_starts + 1) * sizeof(uint32_t)); + if (chars == NULL) + break; for( ; i < glyph_ends; i++) { int this_width; @@ -1626,6 +1630,8 @@ static int on_resize(int rows, int cols, if(cols != state->cols) { unsigned char *newtabstops = vterm_allocator_malloc(state->vt, (cols + 7) / 8); + if (newtabstops == NULL) + return 0; /* TODO: This can all be done much more efficiently bytewise */ int col; @@ -1651,6 +1657,8 @@ static int on_resize(int rows, int cols, if(rows != state->rows) { VTermLineInfo *newlineinfo = vterm_allocator_malloc(state->vt, rows * sizeof(VTermLineInfo)); + if (newlineinfo == NULL) + return 0; int row; for(row = 0; row < state->rows && row < rows; row++) {