Patch 8.2.3662

13 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 24, 2021, 10:14:10 AM11/24/21
to vim...@googlegroups.com

Patch 8.2.3662
Problem: Illegal memory access if malloc() fails.
Solution: Check 'foldmethod' is not empty. (closes #9207)
Files: src/fold.c


*** ../vim-8.2.3661/src/fold.c 2021-07-27 21:00:39.745712396 +0100
--- src/fold.c 2021-11-24 15:11:16.084732649 +0000
***************
*** 307,313 ****
int
foldmethodIsManual(win_T *wp)
{
! return (wp->w_p_fdm[3] == 'u');
}

// foldmethodIsIndent() {{{2
--- 307,313 ----
int
foldmethodIsManual(win_T *wp)
{
! return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[3] == 'u');
}

// foldmethodIsIndent() {{{2
***************
*** 327,333 ****
int
foldmethodIsExpr(win_T *wp)
{
! return (wp->w_p_fdm[1] == 'x');
}

// foldmethodIsMarker() {{{2
--- 327,333 ----
int
foldmethodIsExpr(win_T *wp)
{
! return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[1] == 'x');
}

// foldmethodIsMarker() {{{2
***************
*** 337,343 ****
int
foldmethodIsMarker(win_T *wp)
{
! return (wp->w_p_fdm[2] == 'r');
}

// foldmethodIsSyntax() {{{2
--- 337,343 ----
int
foldmethodIsMarker(win_T *wp)
{
! return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[2] == 'r');
}

// foldmethodIsSyntax() {{{2
*** ../vim-8.2.3661/src/version.c 2021-11-24 14:59:12.573593141 +0000
--- src/version.c 2021-11-24 15:13:09.260714187 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3662,
/**/

--
Snoring is prohibited unless all bedroom windows are closed and securely
locked.
[real standing law in Massachusetts, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christ van Willegen

unread,
Nov 24, 2021, 5:28:14 PM11/24/21
to vim...@googlegroups.com
Hi,

Op wo 24 nov. 2021 16:14 schreef Bram Moolenaar <Br...@moolenaar.net>:

Couldn't wp->w_p_fdm itself be NULL?

Christ van Willegen

Bram Moolenaar

unread,
Nov 24, 2021, 5:41:00 PM11/24/21
to vim...@googlegroups.com, Christ van Willegen

Christ van Willegen wrote:

> Patch 8.2.3662
> Problem: Illegal memory access if malloc() fails.
> Solution: Check 'foldmethod' is not empty. (closes #9207)
> Files: src/fold.c

[...]

> int
> foldmethodIsManual(win_T *wp)
> {
> ! return (wp->w_p_fdm[0] != NUL && wp->w_p_fdm[3] == 'u');
> }

> Couldn't wp->w_p_fdm itself be NULL?

No, string options that can't be set use "empty_option", which is an
empty string. That avoids a lot of NULL pointer checks.

--
My Go, this amn keyboar oesn't have a .
Reply all
Reply to author
Forward
0 new messages