]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1593: MS-Windows: assert error when compiled with debug mode v9.0.1593
authorK.Takata <kentkt@csc.jp>
Wed, 31 May 2023 11:47:45 +0000 (12:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 31 May 2023 11:47:45 +0000 (12:47 +0100)
Problem:    MS-Windows: assert error when compiled with debug mode.
Solution:   Adjust arguments to setvbuf(). (Ken Takata, closes #12467)

src/alloc.c
src/main.c
src/proto/main.pro
src/version.c

index e3e6d0430bae40a83815ac51add280fa1ab84624..fa92c56e58ea969be8a2f8a672a9d471e41b2f4c 100644 (file)
@@ -580,6 +580,7 @@ free_all_mem(void)
 # ifdef FEAT_EVAL
     free_resub_eval_result();
 # endif
+    free_vbuf();
 }
 #endif
 
index 0e8e82cd4f8cc7f602f54cb037cde34bbcda843b..cca53fe256d522fe8bbec6581c81db9d15623a97 100644 (file)
@@ -76,6 +76,10 @@ static char *(main_errors[]) =
 // Various parameters passed between main() and other functions.
 static mparm_T params;
 
+#ifdef _IOLBF
+static void *s_vbuf = NULL;            // buffer for setvbuf()
+#endif
+
 #ifndef NO_VIM_MAIN    // skip this for unittests
 
 static char_u *start_dir = NULL;       // current working dir on startup
@@ -353,10 +357,14 @@ main
     check_tty(&params);
 
 #ifdef _IOLBF
-    // Ensure output works usefully without a tty: buffer lines instead of
-    // fully buffered.
     if (silent_mode)
-       setvbuf(stdout, NULL, _IOLBF, 0);
+    {
+       // Ensure output works usefully without a tty: buffer lines instead of
+       // fully buffered.
+       s_vbuf = malloc(BUFSIZ);
+       if (s_vbuf != NULL)
+           setvbuf(stdout, s_vbuf, _IOLBF, BUFSIZ);
+    }
 #endif
 
     // This message comes before term inits, but after setting "silent_mode"
@@ -1027,6 +1035,21 @@ is_not_a_term_or_gui(void)
        ;
 }
 
+#if defined(EXITFREE) || defined(PROTO)
+    void
+free_vbuf(void)
+{
+# ifdef _IOLBF
+    if (s_vbuf != NULL)
+    {
+       setvbuf(stdout, NULL, _IONBF, 0);
+       free(s_vbuf);
+       s_vbuf = NULL;
+    }
+# endif
+}
+#endif
+
 #if defined(FEAT_GUI) || defined(PROTO)
 /*
  * If a --gui-dialog-file argument was given return the file name.
index 307b6063c0fff53e45080d43ab8cc321f95ce479..496fe66be6950da91917a8b9e38cee7722985e37 100644 (file)
@@ -3,6 +3,7 @@ int vim_main2(void);
 void common_init(mparm_T *paramp);
 int is_not_a_term(void);
 int is_not_a_term_or_gui(void);
+void free_vbuf(void);
 char_u *get_gui_dialog_file(void);
 int op_pending(void);
 void may_trigger_safestate(int safe);
index 45e5b58cf124cfabe7164a6b64192bebc092a8b4..3f0eb0d84e6d9abde5dfa7d334d3912d22d3408c 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1593,
 /**/
     1592,
 /**/