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/popupmnu.c | |
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/popupmnu.c')
-rw-r--r-- | src/popupmnu.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/popupmnu.c b/src/popupmnu.c index ba9c7adc7..2639d97d5 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -1102,12 +1102,19 @@ split_message(char_u *mesg, pumitem_T **array) else thislen = item->bytelen; - /* put indent at the start */ + // put indent at the start p = alloc(thislen + item->indent * 2 + 1); + if (p == NULL) + { + for (line = 0; line <= height - 1; ++line) + vim_free((*array)[line].pum_text); + vim_free(*array); + goto failed; + } for (ind = 0; ind < item->indent * 2; ++ind) p[ind] = ' '; - /* exclude spaces at the end of the string */ + // exclude spaces at the end of the string for (copylen = thislen; copylen > 0; --copylen) if (item->start[skip + copylen - 1] != ' ') break; |