mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
No OOM in autoload_name()
This commit is contained in:
@@ -17008,7 +17008,6 @@ void ex_function(exarg_T *eap)
|
||||
int j = FAIL;
|
||||
if (sourcing_name != NULL) {
|
||||
scriptname = autoload_name(name);
|
||||
if (scriptname != NULL) {
|
||||
p = vim_strchr(scriptname, '/');
|
||||
plen = (int)STRLEN(p);
|
||||
slen = (int)STRLEN(sourcing_name);
|
||||
@@ -17017,7 +17016,6 @@ void ex_function(exarg_T *eap)
|
||||
j = OK;
|
||||
free(scriptname);
|
||||
}
|
||||
}
|
||||
if (j == FAIL) {
|
||||
EMSG2(_(
|
||||
"E746: Function name does not match script file name: %s"),
|
||||
@@ -17638,21 +17636,20 @@ script_autoload (
|
||||
|
||||
/*
|
||||
* Return the autoload script name for a function or variable name.
|
||||
* Returns NULL when out of memory.
|
||||
*/
|
||||
static char_u *autoload_name(char_u *name)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *scriptname;
|
||||
|
||||
/* Get the script file name: replace '#' with '/', append ".vim". */
|
||||
scriptname = xmalloc(STRLEN(name) + 14);
|
||||
char_u *scriptname = xmalloc(STRLEN(name) + 14);
|
||||
STRCPY(scriptname, "autoload/");
|
||||
STRCAT(scriptname, name);
|
||||
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
|
||||
STRCAT(scriptname, ".vim");
|
||||
|
||||
char_u *p;
|
||||
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
|
||||
*p = '/';
|
||||
|
||||
return scriptname;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user