mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0087: crash in command line expansion when out of memory
Problem: Crash in command line expansion when out of memory. Solution: Check for NULL pointer. Also make ExpandGeneric() static. (Dominique Pelle, closes #5437)
This commit is contained in:
parent
ab782c5b6f
commit
61d7c0d52c
@ -16,6 +16,9 @@
|
|||||||
static int cmd_showtail; // Only show path tail in lists ?
|
static int cmd_showtail; // Only show path tail in lists ?
|
||||||
|
|
||||||
static void set_expand_context(expand_T *xp);
|
static void set_expand_context(expand_T *xp);
|
||||||
|
static int ExpandGeneric(expand_T *xp, regmatch_T *regmatch,
|
||||||
|
int *num_file, char_u ***file,
|
||||||
|
char_u *((*func)(expand_T *, int)), int escaped);
|
||||||
static int ExpandFromContext(expand_T *xp, char_u *, int *, char_u ***, int);
|
static int ExpandFromContext(expand_T *xp, char_u *, int *, char_u ***, int);
|
||||||
static int expand_showtail(expand_T *xp);
|
static int expand_showtail(expand_T *xp);
|
||||||
static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg);
|
static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg);
|
||||||
@ -2214,7 +2217,7 @@ ExpandFromContext(
|
|||||||
*
|
*
|
||||||
* Returns OK when no problems encountered, FAIL for error (out of memory).
|
* Returns OK when no problems encountered, FAIL for error (out of memory).
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
ExpandGeneric(
|
ExpandGeneric(
|
||||||
expand_T *xp,
|
expand_T *xp,
|
||||||
regmatch_T *regmatch,
|
regmatch_T *regmatch,
|
||||||
@ -2250,6 +2253,13 @@ ExpandGeneric(
|
|||||||
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);
|
||||||
|
if (str == NULL)
|
||||||
|
{
|
||||||
|
FreeWild(count, *file);
|
||||||
|
*num_file = 0;
|
||||||
|
*file = NULL;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
(*file)[count] = str;
|
(*file)[count] = str;
|
||||||
# ifdef FEAT_MENU
|
# ifdef FEAT_MENU
|
||||||
if (func == get_menu_names && str != NULL)
|
if (func == get_menu_names && str != NULL)
|
||||||
@ -2268,13 +2278,14 @@ ExpandGeneric(
|
|||||||
{
|
{
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return OK;
|
return OK;
|
||||||
*num_file = count;
|
|
||||||
*file = ALLOC_MULT(char_u *, count);
|
*file = ALLOC_MULT(char_u *, count);
|
||||||
if (*file == NULL)
|
if (*file == NULL)
|
||||||
{
|
{
|
||||||
*file = (char_u **)"";
|
*num_file = 0;
|
||||||
|
*file = NULL;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
*num_file = count;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2297,7 +2308,6 @@ ExpandGeneric(
|
|||||||
// they don't show up when getting normal highlight names by ID.
|
// they don't show up when getting normal highlight names by ID.
|
||||||
reset_expand_highlight();
|
reset_expand_highlight();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ char_u *sm_gettail(char_u *s);
|
|||||||
char_u *addstar(char_u *fname, int len, int context);
|
char_u *addstar(char_u *fname, int len, int context);
|
||||||
void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline);
|
void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline);
|
||||||
int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches);
|
int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches);
|
||||||
int ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)), int escaped);
|
|
||||||
void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options);
|
void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options);
|
||||||
void f_getcompletion(typval_T *argvars, typval_T *rettv);
|
void f_getcompletion(typval_T *argvars, typval_T *rettv);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -742,6 +742,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 */
|
||||||
|
/**/
|
||||||
|
87,
|
||||||
/**/
|
/**/
|
||||||
86,
|
86,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user