summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-03-15 22:05:44 +0000
committerBram Moolenaar <Bram@vim.org>2023-03-15 22:05:44 +0000
commit14338024c131b71a337c2bb87cb5904f5a5782b8 (patch)
tree9908621e9379220c400ccbaba4f782c9c62ae941
parente638acc9274112ca5ac6b610b01e44ab2a1e19ce (diff)
patch 9.0.1405: missing check for out-of-memoryv9.0.1405
Problem: Missing check for out-of-memory. Solution: Check for alloc() returning NULL pointer. (closes #12149)
-rw-r--r--src/option.c30
-rw-r--r--src/version.c2
2 files changed, 18 insertions, 14 deletions
diff --git a/src/option.c b/src/option.c
index a2ab5c6663..4d9da472fa 100644
--- a/src/option.c
+++ b/src/option.c
@@ -126,15 +126,14 @@ set_init_default_backupskip(void)
#endif
int len;
garray_T ga;
- int mustfree;
- char_u *item;
+ char_u *item;
opt_idx = findoption((char_u *)"backupskip");
ga_init2(&ga, 1, 100);
for (n = 0; n < (long)ARRAY_LENGTH(names); ++n)
{
- mustfree = FALSE;
+ int mustfree = FALSE;
#ifdef UNIX
if (*names[n] == NUL)
# ifdef MACOS_X
@@ -150,19 +149,22 @@ set_init_default_backupskip(void)
// First time count the NUL, otherwise count the ','.
len = (int)STRLEN(p) + 3;
item = alloc(len);
- STRCPY(item, p);
- add_pathsep(item);
- STRCAT(item, "*");
- if (find_dup_item(ga.ga_data, item, options[opt_idx].flags)
- == NULL
- && ga_grow(&ga, len) == OK)
+ if (item != NULL)
{
- if (ga.ga_len > 0)
- STRCAT(ga.ga_data, ",");
- STRCAT(ga.ga_data, item);
- ga.ga_len += len;
+ STRCPY(item, p);
+ add_pathsep(item);
+ STRCAT(item, "*");
+ if (find_dup_item(ga.ga_data, item, options[opt_idx].flags)
+ == NULL
+ && ga_grow(&ga, len) == OK)
+ {
+ if (ga.ga_len > 0)
+ STRCAT(ga.ga_data, ",");
+ STRCAT(ga.ga_data, item);
+ ga.ga_len += len;
+ }
+ vim_free(item);
}
- vim_free(item);
}
if (mustfree)
vim_free(p);
diff --git a/src/version.c b/src/version.c
index cad03e6811..733eb46e17 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1405,
+/**/
1404,
/**/
1403,