Mercurial > vim
comparison src/popupmnu.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 | 0f65f2808470 |
children | ff3c99bd1038 |
comparison
equal
deleted
inserted
replaced
16428:6f69ef2913d7 | 16429:a1229400434a |
---|---|
1100 thislen = p - (item->start + skip); | 1100 thislen = p - (item->start + skip); |
1101 } | 1101 } |
1102 else | 1102 else |
1103 thislen = item->bytelen; | 1103 thislen = item->bytelen; |
1104 | 1104 |
1105 /* put indent at the start */ | 1105 // put indent at the start |
1106 p = alloc(thislen + item->indent * 2 + 1); | 1106 p = alloc(thislen + item->indent * 2 + 1); |
1107 if (p == NULL) | |
1108 { | |
1109 for (line = 0; line <= height - 1; ++line) | |
1110 vim_free((*array)[line].pum_text); | |
1111 vim_free(*array); | |
1112 goto failed; | |
1113 } | |
1107 for (ind = 0; ind < item->indent * 2; ++ind) | 1114 for (ind = 0; ind < item->indent * 2; ++ind) |
1108 p[ind] = ' '; | 1115 p[ind] = ' '; |
1109 | 1116 |
1110 /* exclude spaces at the end of the string */ | 1117 // exclude spaces at the end of the string |
1111 for (copylen = thislen; copylen > 0; --copylen) | 1118 for (copylen = thislen; copylen > 0; --copylen) |
1112 if (item->start[skip + copylen - 1] != ' ') | 1119 if (item->start[skip + copylen - 1] != ' ') |
1113 break; | 1120 break; |
1114 | 1121 |
1115 vim_strncpy(p + ind, item->start + skip, copylen); | 1122 vim_strncpy(p + ind, item->start + skip, copylen); |