mirror of
https://github.com/neovim/neovim.git
synced 2025-11-15 14:59:20 +00:00
vim-patch:9.1.1467: too many strlen() calls (#34572)
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: vim/vim#17561
fff0132399
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -1449,11 +1449,10 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
|
||||
// copy file name into NameBuff, expanding environment variables
|
||||
char save_char = ptr[len];
|
||||
ptr[len] = NUL;
|
||||
expand_env_esc(ptr, NameBuff, MAXPATHL, false, true, NULL);
|
||||
file_to_findlen = expand_env_esc(ptr, NameBuff, MAXPATHL, false, true, NULL);
|
||||
ptr[len] = save_char;
|
||||
|
||||
xfree(*file_to_find);
|
||||
file_to_findlen = strlen(NameBuff);
|
||||
*file_to_find = xmemdupz(NameBuff, file_to_findlen);
|
||||
if (options & FNAME_UNESC) {
|
||||
// Change all "\ " to " ".
|
||||
|
||||
Reference in New Issue
Block a user