From dc634ca4666a787495857da707b495cea8af8b94 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 21 Sep 2022 19:31:52 +0300
Subject: [PATCH 25/25] Increase size of the buffer of fc_vsnprintf() fallback
 implementation

The old internal buffer was 8k. Preparing secfile for saving may request
handling of buffers of 8096k.

See osdn #45682

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 utility/ioz.c     | 3 +++
 utility/support.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/utility/ioz.c b/utility/ioz.c
index 0d0489696c..a2e901654c 100644
--- a/utility/ioz.c
+++ b/utility/ioz.c
@@ -72,7 +72,10 @@ struct bzip2_struct {
 
 #ifdef FREECIV_HAVE_LIBLZMA
 
+/* If you increase size of this, be sure to increase also
+ * VSNP_BUF_SIZE in support.c so that this still fits in. */
 #define PLAIN_FILE_BUF_SIZE (8096*1024)    /* 8096kb */
+
 #define XZ_DECODER_TEST_SIZE (4*1024)      /* 4kb */
 
 /* In my tests 7Mb proved to be not enough and with 10Mb decompression
diff --git a/utility/support.c b/utility/support.c
index d49207edac..34342e742c 100644
--- a/utility/support.c
+++ b/utility/support.c
@@ -868,8 +868,8 @@ size_t fc_strlcat(char *dest, const char *src, size_t n)
   See also fc_utf8_vsnprintf_trunc(), fc_utf8_vsnprintf_rep().
 ****************************************************************************/
 
-/* "64k should be big enough for anyone" ;-) */
-#define VSNP_BUF_SIZE (64*1024)
+/* This must be at least as big as PLAIN_FILE_BUF_SIZE in ioz.c */
+#define VSNP_BUF_SIZE (8096*1024)
 int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
 {
 #ifdef HAVE_WORKING_VSNPRINTF
-- 
2.35.1