ex_getln: Fix PVS/V560: there are no longer NULL returns for OOM

This commit is contained in:
ZyX
2018-04-15 19:38:22 +03:00
parent cad616c94e
commit c90e9df5b5

View File

@@ -4856,26 +4856,30 @@ void ExpandGeneric(
// copy the matching names into allocated memory // copy the matching names into allocated memory
count = 0; count = 0;
for (i = 0;; ++i) { for (i = 0;; i++) {
str = (*func)(xp, i); str = (*func)(xp, i);
if (str == NULL) // end of list if (str == NULL) { // end of list
break; break;
if (*str == NUL) // skip empty strings }
if (*str == NUL) { // skip empty strings
continue; continue;
}
if (vim_regexec(regmatch, str, (colnr_T)0)) { if (vim_regexec(regmatch, str, (colnr_T)0)) {
if (escaped) if (escaped) {
str = vim_strsave_escaped(str, (char_u *)" \t\\."); str = vim_strsave_escaped(str, (char_u *)" \t\\.");
else } else {
str = vim_strsave(str); str = vim_strsave(str);
}
(*file)[count++] = str; (*file)[count++] = str;
if (func == get_menu_names && str != NULL) { if (func == get_menu_names) {
/* test for separator added by get_menu_names() */ // Test for separator added by get_menu_names().
str += STRLEN(str) - 1; str += STRLEN(str) - 1;
if (*str == '\001') if (*str == '\001') {
*str = '.'; *str = '.';
} }
} }
} }
}
/* Sort the results. Keep menu's in the specified order. */ /* Sort the results. Keep menu's in the specified order. */
if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS) { if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS) {