diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-27 22:06:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-27 22:06:37 +0200 |
commit | 6ee9658774942f7448af700fc04df0335796a3db (patch) | |
tree | 87f99c37e22f07e73e244da78686c7e59a8457f1 /src/libvterm | |
parent | 00aa069db8132851a91cfc5ca7f58ef945c75c73 (diff) | |
download | vim-git-6ee9658774942f7448af700fc04df0335796a3db.tar.gz |
patch 8.1.1219: not checking for NULL return from alloc()v8.1.1219
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes #4303, closes #4174)
Diffstat (limited to 'src/libvterm')
-rw-r--r-- | src/libvterm/src/state.c | 8 | ||||
-rw-r--r-- | src/libvterm/src/termscreen.c | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c index a1261455f..d6ac29deb 100644 --- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -253,6 +253,8 @@ static int on_text(const char bytes[], size_t len, void *user) // 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[], size_t len, void *user) 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, void *user) 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, void *user) 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++) { diff --git a/src/libvterm/src/termscreen.c b/src/libvterm/src/termscreen.c index 0cd31cedf..4e94cfbc6 100644 --- a/src/libvterm/src/termscreen.c +++ b/src/libvterm/src/termscreen.c @@ -83,6 +83,8 @@ static ScreenCell *realloc_buffer(VTermScreen *screen, ScreenCell *buffer, int n ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); int row, col; + if (new_buffer == NULL) + return NULL; for(row = 0; row < new_rows; row++) { for(col = 0; col < new_cols; col++) { ScreenCell *new_cell = new_buffer + row*new_cols + col; |