patch 9.1.1097: --log with non-existent path causes a crash Commit: https://github.com/vim/vim/commit/c5654b84480822817bb7b69ebc97c174c91185e9 Author: Hirohito Higashi <h.east....@gmail.com> Date: Mon Feb 10 20:55:17 2025 +0100
patch 9.1.1097: --log with non-existent path causes a crash Problem: --log with non-existent path causes a crash (Ekkosun) Solution: split initialization phase and init the execution stack earlier (Hirohito Higashi) fixes: #16606 closes: #16610 Signed-off-by: Hirohito Higashi <h.east....@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/main.c b/src/main.c index ecc61f4d0..f603a52a5 100644 --- a/src/main.c +++ b/src/main.c @@ -144,6 +144,11 @@ main atexit(vim_mem_profile_dump); #endif + /* + * Various initialisations #1 shared with tests. + */ + common_init_1(); + #if defined(STARTUPTIME) || defined(FEAT_JOB_CHANNEL) // Need to find "--startuptime" and "--log" before actually parsing // arguments. @@ -185,9 +190,9 @@ main #endif /* - * Various initialisations shared with tests. + * Various initialisations #2 shared with tests. */ - common_init(¶ms); + common_init_2(¶ms); #ifdef VIMDLL // Check if the current executable file is for the GUI subsystem. @@ -900,10 +905,10 @@ vim_main2(void) } /* - * Initialisation shared by main() and some tests. + * Initialisation #1 shared by main() and some tests. */ void -common_init(mparm_T *paramp) +common_init_1(void) { estack_init(); cmdline_init(); @@ -925,7 +930,15 @@ common_init(mparm_T *paramp) || (NameBuff = alloc(MAXPATHL)) == NULL) mch_exit(0); TIME_MSG("Allocated generic buffers"); +} + +/* + * Initialisation #2 shared by main() and some tests. + */ + void +common_init_2(mparm_T *paramp) +{ #ifdef NBDEBUG // Wait a moment for debugging NetBeans. Must be after allocating // NameBuff. diff --git a/src/message_test.c b/src/message_test.c index 62f777247..83767ece9 100644 --- a/src/message_test.c +++ b/src/message_test.c @@ -508,7 +508,8 @@ main(int argc, char **argv) CLEAR_FIELD(params); params.argc = argc; params.argv = argv; - common_init(¶ms); + common_init_1(); + common_init_2(¶ms); set_option_value_give_err((char_u *)"encoding", 0, (char_u *)"utf-8", 0); init_chartab(); diff --git a/src/proto/main.pro b/src/proto/main.pro index 496fe66be..7e4c50803 100644 --- a/src/proto/main.pro +++ b/src/proto/main.pro @@ -1,6 +1,7 @@ /* main.c */ int vim_main2(void); -void common_init(mparm_T *paramp); +void common_init_1(void); +void common_init_2(mparm_T *paramp); int is_not_a_term(void); int is_not_a_term_or_gui(void); void free_vbuf(void); diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 7c7039160..c16e4ae27 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -740,6 +740,13 @@ func Test_log() call delete('Xlogfile') endfunc +func Test_log_nonexistent() + " this used to crash Vim + CheckFeature channel + let result = join(systemlist(GetVimCommand() .. ' --log /X/Xlogfile -c qa!')) + call assert_match("E484: Can't open file", result) +endfunc + func Test_read_stdin() let after =<< trim [CODE] write Xtestout diff --git a/src/version.c b/src/version.c index be4b7e74b..0a254e5cf 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1097, /**/ 1096, /**/ -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1thaBM-001Frj-7W%40256bit.org.