From b443fb1a5b3b0f0ffb419c2eb7a7375c9d5b990e Mon Sep 17 00:00:00 2001
Date: Wed, 15 Oct 2025 12:41:10 +0400
Subject: [PATCH] Fix timestamptz_to_str() for out-of-range timestamps
---
src/bin/pg_waldump/compat.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/bin/pg_waldump/compat.c b/src/bin/pg_waldump/compat.c
index 2aca73f2e93..825311b1bd4 100644
--- a/src/bin/pg_waldump/compat.c
+++ b/src/bin/pg_waldump/compat.c
@@ -54,6 +54,12 @@ timestamptz_to_str(TimestampTz t)
time_t result = (time_t) timestamptz_to_time_t(t);
struct tm *ltime = localtime(&result);
+ if (!ltime)
+ {
+ strlcpy(buf, "(timestamp out of range)", sizeof(buf));
+ return buf;
+ }
+
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", ltime);
strftime(zone, sizeof(zone), "%Z", ltime);
--
2.43.0