Patch 8.2.1553 (after 8.2.1552)
Problem:    Crash in edit test.
Solution:   Avoid using invalid pointer.
Files:      src/fold.c


*** ../vim-8.2.1552/src/fold.c  2020-08-31 19:58:10.032399977 +0200
--- src/fold.c  2020-08-31 21:13:49.001498809 +0200
***************
*** 608,642 ****
  
      // Find the place to insert the new fold.
      gap = &curwin->w_folds;
!     for (;;)
      {
!       if (!foldFind(gap, start_rel, &fp))
!           break;
!       if (fp->fd_top + fp->fd_len > end_rel)
        {
!           // New fold is completely inside this fold: Go one level deeper.
!           gap = &fp->fd_nested;
!           start_rel -= fp->fd_top;
!           end_rel -= fp->fd_top;
!           if (use_level || fp->fd_flags == FD_LEVEL)
            {
!               use_level = TRUE;
!               if (level >= curwin->w_p_fdl)
                    closed = TRUE;
            }
-           else if (fp->fd_flags == FD_CLOSED)
-               closed = TRUE;
-           ++level;
-       }
-       else
-       {
-           // This fold and new fold overlap: Insert here and move some folds
-           // inside the new fold.
-           break;
        }
      }
  
-     i = (int)(fp - (fold_T *)gap->ga_data);
      if (ga_grow(gap, 1) == OK)
      {
        fp = (fold_T *)gap->ga_data + i;
--- 608,648 ----
  
      // Find the place to insert the new fold.
      gap = &curwin->w_folds;
!     if (gap->ga_len == 0)
!       i = 0;
!     else
      {
!       for (;;)
        {
!           if (!foldFind(gap, start_rel, &fp))
!               break;
!           if (fp->fd_top + fp->fd_len > end_rel)
            {
!               // New fold is completely inside this fold: Go one level
!               // deeper.
!               gap = &fp->fd_nested;
!               start_rel -= fp->fd_top;
!               end_rel -= fp->fd_top;
!               if (use_level || fp->fd_flags == FD_LEVEL)
!               {
!                   use_level = TRUE;
!                   if (level >= curwin->w_p_fdl)
!                       closed = TRUE;
!               }
!               else if (fp->fd_flags == FD_CLOSED)
                    closed = TRUE;
+               ++level;
+           }
+           else
+           {
+               // This fold and new fold overlap: Insert here and move some
+               // folds inside the new fold.
+               break;
            }
        }
+       i = (int)(fp - (fold_T *)gap->ga_data);
      }
  
      if (ga_grow(gap, 1) == OK)
      {
        fp = (fold_T *)gap->ga_data + i;
*** ../vim-8.2.1552/src/version.c       2020-08-31 19:58:10.032399977 +0200
--- src/version.c       2020-08-31 21:08:24.462316287 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1553,
  /**/

-- 
Q:  Why do ducks have flat feet?
A:  To stamp out forest fires.

Q:  Why do elephants have flat feet?
A:  To stamp out flaming ducks.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202008311915.07VJFRoO3128579%40masaka.moolenaar.net.

Raspunde prin e-mail lui