From: Bram Moolenaar Date: Wed, 24 Nov 2021 15:13:26 +0000 (+0000) Subject: patch 8.2.3662: illegal memory access if malloc() fails X-Git-Tag: v8.2.3662 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf1e0239ceec96396fa51f494e442c799ccd45fb;p=vim patch 8.2.3662: illegal memory access if malloc() fails Problem: Illegal memory access if malloc() fails. Solution: Check 'foldmethod' is not empty. (closes #9207) --- diff --git a/src/fold.c b/src/fold.c index d9cba6a22..d4a626753 100644 --- a/src/fold.c +++ b/src/fold.c @@ -307,7 +307,7 @@ foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop) 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 index 1a3919087..58a185604 100644 --- a/src/version.c +++ b/src/version.c @@ -757,6 +757,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3662, /**/ 3661, /**/