Paul Eggert did:
> (__strftime_internal): Simplify calculation of zone to be closer
> to what glibc does.

This causes 4 test suite failures on Solaris 11.4, from a null pointer
reference:

FAIL: test-c-nstrftime-1.sh
===========================

../../gltests/test-c-nstrftime-1.sh: line 3: 9936: Memory fault(coredump)
FAIL test-c-nstrftime-1.sh (exit status: 1)

FAIL: test-c-nstrftime-2.sh
===========================

../../gltests/test-c-nstrftime-2.sh: line 16: 9941: Memory fault(coredump)
FAIL test-c-nstrftime-2.sh (exit status: 1)

FAIL: test-nstrftime-1.sh
=========================

../../gltests/test-nstrftime-1.sh: line 3: 14141: Memory fault(coredump)
FAIL test-nstrftime-1.sh (exit status: 1)

FAIL: test-nstrftime-2.sh
=========================

../../gltests/test-nstrftime-2.sh: line 18: 14146: Memory fault(coredump)
FAIL test-nstrftime-2.sh (exit status: 1)

It crashes at strftime.c:2032. zone is NULL.

This patch fixes the crash.


2024-06-17  Bruno Haible  <br...@clisp.org>

        nstrftime, c-nstrftime: Fix crash on Solaris 11.4.
        * lib/strftime.c (__strftime_internal): Restore protection against zone
        being NULL.

diff --git a/lib/strftime.c b/lib/strftime.c
index e33dbb8f7c..e422267913 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -949,6 +949,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
         zone = "GMT";
     }
 #endif
+  if (! zone)
+    zone = "";
 
   if (hour12 > 12)
     hour12 -= 12;




Reply via email to