Replace static buf with palloc in str_time()
authorHeikki Linnakangas <[email protected]>
Tue, 30 Jul 2024 19:05:51 +0000 (22:05 +0300)
committerHeikki Linnakangas <[email protected]>
Tue, 30 Jul 2024 19:05:51 +0000 (22:05 +0300)
The function is used only once in the startup process, so the leak
into current memory context is harmless.

This is a tiny step in making the server thread-safe.

Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0358@iki.fi

src/backend/access/transam/xlog.c

index f86f4b5c4b73b048b0d48d9d6d36727e58ac4a42..75463e153ece6efc83066ce482538dc61a626325 100644 (file)
@@ -5168,9 +5168,9 @@ BootStrapXLOG(uint32 data_checksum_version)
 static char *
 str_time(pg_time_t tnow)
 {
-   static char buf[128];
+   char       *buf = palloc(128);
 
-   pg_strftime(buf, sizeof(buf),
+   pg_strftime(buf, 128,
                "%Y-%m-%d %H:%M:%S %Z",
                pg_localtime(&tnow, log_timezone));