Problem: a few memory leaks are found
(LuMingYinDetect )
Solution: properly free the memory
Fixes the following problems:
- Memory leak in f_maplist()
fixes: #14486
- Memory leak in option.c
fixes: #14485
- Memory leak in f_resolve()
fixes: #14484
- Memory leak in f_autocmd_get()
related: #14474
- Memory leak in dict_extend_func()
fixes: #14477fixes: #14238closes: #14517
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: is*() and to*() function may be unsafe
Solution: Add SAFE_* macros and start using those instead
(Keith Thompson)
Use SAFE_() macros for is*() and to*() functions
The standard is*() and to*() functions declared in <ctype.h> have
undefined behavior for negative arguments other than EOF. If plain char
is signed, passing an unchecked value from argv for from user input
to one of these functions has undefined behavior.
Solution: Add SAFE_*() macros that cast the argument to unsigned char.
Most implementations behave sanely for negative arguments, and most
character values in practice are non-negative, but it's still best
to avoid undefined behavior.
The change from #13347 has been omitted, as this has already been
separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a
(v9.0.2054)
fixes: #13332closes: #13347
Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: gcc overflow-warning for f_resolve
Solution: use pointer p instead of pointer q[-1]
Suppress the following warning:
```
filepath.c: In function ‘f_resolve’:
filepath.c:2162:27: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
2162 | q[-1] = NUL;
```
Closes: #13352closes: #13353
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ken Takata <kentkt@csc.jp>
Problem: Fix regression in {func} argument of reduce()
Solution: pass function name as string again
Before patch 9.0.0548, passing a string as {func} argument of reduce()
is treated as a function name, but after patch 9.0.0548 it is treated as
an expression instead, which is useless as reduce() doesn't set any v:
variables. This PR restores the behavior of {func} before that patch.
Also correct an emsg() call, as e_string_list_or_blob_required doesn't
contain format specifiers.
closes: #12824
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem: Evaluating "expr" options has more overhead than needed.
Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr',
"expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr',
'formatexpr', 'indentexpr' and 'charconvert'.
Problem: Only created files can be cleaned up with one call.
Solution: Add flags to mkdir() to delete with a deferred function.
Expand the writefile() name to a full path to handle changing
directory.
Problem: Empty string considered an error for expand() when 'verbose' is
set. (Christian Brabandt)
Solution: Do not give an error for an empty result. (closes#10307)
Problem: Cannot have expandcmd() give an error message for mistakes.
Solution: Add an optional argument to give errors. Fix memory leak when
expanding files fails. (Yegappan Lakshmanan, closes#10071)
Problem: 'wildignorecase' is sometimes not used for glob().
Solution: Also use 'wildignorecase' when there are no wildcards.
(closes#10066, closes#8350)
Problem: getcwd() is unclear about how 'autochdir' is used.
Solution: Update the help for getcwd(). Without any arguments always return
the actual current directory. (closes#9142)
Problem: Vim9: runtime and compile time type checks are not the same.
Solution: Add more runtime type checks for builtin functions. (Yegappan
Lakshmanan, closes#8646)
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks. Sort the argument lists.
(Yegappan Lakshmanan, closes#8626)
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks, also at runtime. (Yegappan
Lakshmanan, closes#8587)