+2024-06-18 Bruno Haible <bruno@clisp.org>
+
+ nstrftime: Fix crash on NetBSD 10.0.
+ * lib/strftime.c (utc_timezone_cache): New variable.
+ (utc_timezone): New function.
+ (underlying_strftime): Use it when tz is NULL.
+
2024-06-18 Bruno Haible <bruno@clisp.org>
c-nstrftime: Fix warning on platforms without strftime_l.
#endif
+#if HAVE_NATIVE_TIME_Z
+
+/* Cache for the UTC time zone object.
+ Marked volatile so that different threads see the same value
+ (avoids locking). */
+static volatile timezone_t utc_timezone_cache;
+
+/* Return the UTC time zone object, or (timezone_t) 0 with errno set
+ if it cannot be created. */
+static timezone_t
+utc_timezone (void)
+{
+ if (!utc_timezone_cache)
+ utc_timezone_cache = tzalloc ("UTC");
+ return utc_timezone_cache;
+}
+
+#endif
+
#if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM
*u++ = format_char;
*u = '\0';
+# if HAVE_NATIVE_TIME_Z
+ if (!tz)
+ {
+ tz = utc_timezone ();
+ if (!tz)
+ return 0; /* errno is set here */
+ }
+# endif
+
# if !HAVE_NATIVE_TIME_Z
if (tz && tz != local_tz)
{