scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit b843da74b79d585a30bd2b3f13e7c63d105baf94
parent 7e3a98c60416721729db2b8ed87c722e30e85fda
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 16 May 2022 10:42:43 +0200

libc: Initialize internal fields in gmtime()

Gmtime() converst a time_t date into a breakdown struct tm
based in GMT timezone. Struct tm has a few internal fields
that are used in some other time.h functions, like for
example strftime, and they were not initialized by gmtime()
producing random segfaults at execution time.

Diffstat:
Msrc/libc/time/gmtime.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/libc/time/gmtime.c b/src/libc/time/gmtime.c @@ -32,6 +32,8 @@ gmtime(const time_t *tim) tm.tm_mday = day + 1; tm.tm_isdst = 0; + tm.tm_zone = "GMT"; + tm.tm_gmtoff = 0; return &tm; }