# HG changeset patch # User Bram Moolenaar # Date 1637766903 -3600 # Node ID 2484d6d9616629fe51bad8a8e58199a1f3c08a04 # Parent 4aee351f48a4b84f6ff5bb66758eec95d9f91f85 patch 8.2.3662: illegal memory access if malloc() fails Commit: https://github.com/vim/vim/commit/cf1e0239ceec96396fa51f494e442c799ccd45fb Author: Bram Moolenaar Date: Wed Nov 24 15:13:26 2021 +0000 patch 8.2.3662: illegal memory access if malloc() fails Problem: Illegal memory access if malloc() fails. Solution: Check 'foldmethod' is not empty. (closes https://github.com/vim/vim/issues/9207) diff --git a/src/fold.c b/src/fold.c --- a/src/fold.c +++ b/src/fold.c @@ -307,7 +307,7 @@ foldedCount(win_T *win, linenr_T lnum, f int 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 @@ -327,7 +327,7 @@ foldmethodIsIndent(win_T *wp) int 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 @@ -337,7 +337,7 @@ foldmethodIsExpr(win_T *wp) int 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3662, +/**/ 3661, /**/ 3660,