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 #4303, closes #4174)
diff --git a/src/popupmnu.c b/src/popupmnu.c
index ba9c7ad..2639d97 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -1102,12 +1102,19 @@
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;