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.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/main.c b/src/main.c
index ecc61f4..f603a52 100644
--- a/src/main.c
+++ b/src/main.c
@@ -144,6 +144,11 @@
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 @@
#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 @@
}
/*
- * 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 @@
|| (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.