From 69ea026fbcfeeb81110ab5b88012d0efde2c2f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Sat, 2 Dec 2017 11:39:12 +0000 Subject: [PATCH] Fix a 32-bit time_t cast Divide first, *then* cast. Otherwise a very long "now", which is 64-bit, gets truncated into a 32-bit time_t, which can't hold the value, and turns negative more often than not. https://bugzilla.gnome.org/show_bug.cgi?id=791128 --- glib/gmessages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gmessages.c b/glib/gmessages.c index 8c9f558a9..cb2abd5fd 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -2268,7 +2268,7 @@ g_log_writer_format_fields (GLogLevelFlags log_level, /* Timestamp */ now = g_get_real_time (); - now_secs = (time_t) now / 1000000; + now_secs = (time_t) (now / 1000000); now_tm = localtime (&now_secs); strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);