mirror of
https://github.com/vim/vim.git
synced 2025-10-27 09:24:23 -04:00
patch 9.1.1467: too many strlen() calls
Problem: too many strlen() calls
Solution: Change expand_env() to return string length
(John Marriott)
This commit does the following changes:
- In expand_env_esc():
- return the length of the returned dst string.
- refactor to remove some calls to STRLEN() and STRCAT()
- add check for out-of-memory condition.
- Change call sites in various source files to use the return value
closes: #17561
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
8311e7d6b4
commit
fff0132399
@@ -548,8 +548,7 @@ cs_add_common(
|
||||
if ((fname = alloc(MAXPATHL + 1)) == NULL)
|
||||
goto add_err;
|
||||
|
||||
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
|
||||
len = STRLEN(fname);
|
||||
len = expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
|
||||
fbuf = (char_u *)fname;
|
||||
(void)modify_fname((char_u *)":p", FALSE, &usedlen,
|
||||
(char_u **)&fname, &fbuf, &len);
|
||||
@@ -829,6 +828,7 @@ cs_create_connection(int i)
|
||||
int cmdlen;
|
||||
int len;
|
||||
char *prog, *cmd, *ppath = NULL;
|
||||
size_t proglen;
|
||||
#ifdef MSWIN
|
||||
int fd;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
@@ -916,10 +916,10 @@ err_closing:
|
||||
goto err_closing;
|
||||
#endif
|
||||
}
|
||||
expand_env(p_csprg, (char_u *)prog, MAXPATHL);
|
||||
proglen = expand_env(p_csprg, (char_u *)prog, MAXPATHL);
|
||||
|
||||
// alloc space to hold the cscope command
|
||||
cmdlen = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
|
||||
cmdlen = (int)(proglen + strlen(csinfo[i].fname) + 32);
|
||||
if (csinfo[i].ppath)
|
||||
{
|
||||
// expand the prepend path for env var's
|
||||
@@ -933,9 +933,7 @@ err_closing:
|
||||
goto err_closing;
|
||||
#endif
|
||||
}
|
||||
expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
|
||||
|
||||
cmdlen += (int)strlen(ppath);
|
||||
cmdlen += (int)expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
|
||||
}
|
||||
|
||||
if (csinfo[i].flags)
|
||||
|
||||
Reference in New Issue
Block a user