Patch 8.2.4974
Problem:    ":so" command may read after end of buffer.
Solution:   Compute length of text properly.
Files:      src/scriptfile.c, src/testdir/test_source.vim


*** ../vim-8.2.4973/src/scriptfile.c    2022-04-15 13:53:30.052708679 +0100
--- src/scriptfile.c    2022-05-17 17:45:59.872232695 +0100
***************
*** 1965,1970 ****
--- 1965,1971 ----
                break;
            buf = (char_u *)ga.ga_data;
            buf[ga.ga_len++] = NUL;
+           len = ga.ga_len;
        }
        else
        {
***************
*** 1972,1979 ****
            if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
                        sp->fp) == NULL)
                break;
        }
-       len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
  #ifdef USE_CRNL
        // Ignore a trailing CTRL-Z, when in Dos mode.  Only recognize the
        // CTRL-Z by its own, or after a NL.
--- 1973,1980 ----
            if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
                        sp->fp) == NULL)
                break;
+           len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
        }
  #ifdef USE_CRNL
        // Ignore a trailing CTRL-Z, when in Dos mode.  Only recognize the
        // CTRL-Z by its own, or after a NL.
*** ../vim-8.2.4973/src/testdir/test_source.vim 2022-03-29 19:52:08.787653549 
+0100
--- src/testdir/test_source.vim 2022-05-17 17:45:30.932092316 +0100
***************
*** 652,657 ****
--- 652,668 ----
    norm300gr0
    so
    bwipe!
+ 
+   let lines =<< trim END
+       new
+       norm 10a0000000000ΓΈ00000000000
+       norm i0000000000000000000
+       silent! so
+   END
+   call writefile(lines, 'Xtest.vim')
+   source Xtest.vim
+   bwipe!
+   call delete('Xtest.vim')
  endfunc
  
  
*** ../vim-8.2.4973/src/version.c       2022-05-17 16:12:35.712086412 +0100
--- src/version.c       2022-05-17 17:17:16.470127918 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4974,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
223. You set up a web-cam as your home's security system.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20220517164736.244211C030A%40moolenaar.net.

Raspunde prin e-mail lui