0
0
mirror of https://github.com/vim/vim.git synced 2025-08-26 20:03:41 -04:00

patch 9.1.1218: missing out-of-memory check in filepath.c

Problem:  missing out-of-memory check in filepath.c
Solution: Add check for NULL (John Marriott)

closes: #16906

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
John Marriott 2025-03-17 21:14:17 +01:00 committed by Christian Brabandt
parent 85627732e0
commit c00729824d
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 12 additions and 3 deletions

View File

@ -105,7 +105,9 @@ shortpath_for_invalid_fname(
char_u **bufp, char_u **bufp,
size_t *fnamelen) size_t *fnamelen)
{ {
char_u *short_fname, *save_fname, *pbuf_unused; char_u *save_fname;
char_u *pbuf_unused = NULL;
char_u *short_fname = NULL;
char_u *endp, *save_endp; char_u *endp, *save_endp;
char_u ch; char_u ch;
size_t old_len; size_t old_len;
@ -116,8 +118,11 @@ shortpath_for_invalid_fname(
// Make a copy // Make a copy
old_len = *fnamelen; old_len = *fnamelen;
save_fname = vim_strnsave(*fname, old_len); save_fname = vim_strnsave(*fname, old_len);
pbuf_unused = NULL; if (save_fname == NULL)
short_fname = NULL; {
retval = FAIL;
goto theend;
}
endp = save_fname + old_len - 1; // Find the end of the copy endp = save_fname + old_len - 1; // Find the end of the copy
save_endp = endp; save_endp = endp;
@ -233,6 +238,8 @@ shortpath_for_partial(
pbuf = tfname = expand_env_save(*fnamep); pbuf = tfname = expand_env_save(*fnamep);
else else
pbuf = tfname = FullName_save(*fnamep, FALSE); pbuf = tfname = FullName_save(*fnamep, FALSE);
if (tfname == NULL)
return FAIL;
len = tflen = STRLEN(tfname); len = tflen = STRLEN(tfname);

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1218,
/**/ /**/
1217, 1217,
/**/ /**/