patch 9.0.1593: MS-Windows: assert error when compiled with debug mode

Problem:    MS-Windows: assert error when compiled with debug mode.
Solution:   Adjust arguments to setvbuf(). (Ken Takata, closes #12467)
diff --git a/src/alloc.c b/src/alloc.c
index e3e6d04..fa92c56 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -580,6 +580,7 @@
 # ifdef FEAT_EVAL
     free_resub_eval_result();
 # endif
+    free_vbuf();
 }
 #endif
 
diff --git a/src/main.c b/src/main.c
index 0e8e82c..cca53fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -76,6 +76,10 @@
 // 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 @@
     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 @@
 	;
 }
 
+#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.
diff --git a/src/proto/main.pro b/src/proto/main.pro
index 307b606..496fe66 100644
--- a/src/proto/main.pro
+++ b/src/proto/main.pro
@@ -3,6 +3,7 @@
 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);
diff --git a/src/version.c b/src/version.c
index 45e5b58..3f0eb0d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1593,
+/**/
     1592,
 /**/
     1591,