commit a331d187ba7591f2bbf0841194e96ba0900c1106
parent c50d544d0386ff4f1a48360664b4bae108861da3
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date: Sat, 13 Dec 2025 20:28:13 -0500
vim-patch:8.2.3662: illegal memory access if malloc() fails (#36939)
Problem: Illegal memory access if malloc() fails.
Solution: Check 'foldmethod' is not empty. (closes vim/vim#9207)
https://github.com/vim/vim/commit/cf1e0239ceec96396fa51f494e442c799ccd45fb
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
@@ -322,7 +322,7 @@ foldinfo_T fold_info(win_T *win, linenr_T lnum)
/// @return true if 'foldmethod' is "manual"
bool foldmethodIsManual(win_T *wp)
{
- return wp->w_p_fdm[3] == 'u';
+ return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[3] == 'u');
}
// foldmethodIsIndent() {{{2
@@ -336,14 +336,14 @@ bool foldmethodIsIndent(win_T *wp)
/// @return true if 'foldmethod' is "expr"
bool foldmethodIsExpr(win_T *wp)
{
- return wp->w_p_fdm[1] == 'x';
+ return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[1] == 'x');
}
// foldmethodIsMarker() {{{2
/// @return true if 'foldmethod' is "marker"
bool foldmethodIsMarker(win_T *wp)
{
- return wp->w_p_fdm[2] == 'r';
+ return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[2] == 'r');
}
// foldmethodIsSyntax() {{{2