No OOM in autoload_name()

This commit is contained in:
Felipe Oliveira Carvalho
2014-05-28 23:06:13 -03:00
parent bb978fa69c
commit 9e7d06da41

View File

@@ -17008,7 +17008,6 @@ void ex_function(exarg_T *eap)
int j = FAIL; int j = FAIL;
if (sourcing_name != NULL) { if (sourcing_name != NULL) {
scriptname = autoload_name(name); scriptname = autoload_name(name);
if (scriptname != NULL) {
p = vim_strchr(scriptname, '/'); p = vim_strchr(scriptname, '/');
plen = (int)STRLEN(p); plen = (int)STRLEN(p);
slen = (int)STRLEN(sourcing_name); slen = (int)STRLEN(sourcing_name);
@@ -17017,7 +17016,6 @@ void ex_function(exarg_T *eap)
j = OK; j = OK;
free(scriptname); free(scriptname);
} }
}
if (j == FAIL) { if (j == FAIL) {
EMSG2(_( EMSG2(_(
"E746: Function name does not match script file name: %s"), "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. * 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) static char_u *autoload_name(char_u *name)
{ {
char_u *p;
char_u *scriptname;
/* Get the script file name: replace '#' with '/', append ".vim". */ /* Get the script file name: replace '#' with '/', append ".vim". */
scriptname = xmalloc(STRLEN(name) + 14); char_u *scriptname = xmalloc(STRLEN(name) + 14);
STRCPY(scriptname, "autoload/"); STRCPY(scriptname, "autoload/");
STRCAT(scriptname, name); STRCAT(scriptname, name);
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
STRCAT(scriptname, ".vim"); STRCAT(scriptname, ".vim");
char_u *p;
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL) while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
*p = '/'; *p = '/';
return scriptname; return scriptname;
} }