Skip to content

Commit c007298

Browse files
John Marriottchrisbra
authored andcommitted
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>
1 parent 8562773 commit c007298

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/filepath.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ shortpath_for_invalid_fname(
105105
char_u **bufp,
106106
size_t *fnamelen)
107107
{
108-
char_u *short_fname, *save_fname, *pbuf_unused;
108+
char_u *save_fname;
109+
char_u *pbuf_unused = NULL;
110+
char_u *short_fname = NULL;
109111
char_u *endp, *save_endp;
110112
char_u ch;
111113
size_t old_len;
@@ -116,8 +118,11 @@ shortpath_for_invalid_fname(
116118
// Make a copy
117119
old_len = *fnamelen;
118120
save_fname = vim_strnsave(*fname, old_len);
119-
pbuf_unused = NULL;
120-
short_fname = NULL;
121+
if (save_fname == NULL)
122+
{
123+
retval = FAIL;
124+
goto theend;
125+
}
121126

122127
endp = save_fname + old_len - 1; // Find the end of the copy
123128
save_endp = endp;
@@ -233,6 +238,8 @@ shortpath_for_partial(
233238
pbuf = tfname = expand_env_save(*fnamep);
234239
else
235240
pbuf = tfname = FullName_save(*fnamep, FALSE);
241+
if (tfname == NULL)
242+
return FAIL;
236243

237244
len = tflen = STRLEN(tfname);
238245

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1218,
707709
/**/
708710
1217,
709711
/**/

0 commit comments

Comments
 (0)