mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-10 03:04:05 +02:00
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
This commit is contained in:
@@ -2268,7 +2268,7 @@ g_log_writer_format_fields (GLogLevelFlags log_level,
|
|||||||
|
|
||||||
/* Timestamp */
|
/* Timestamp */
|
||||||
now = g_get_real_time ();
|
now = g_get_real_time ();
|
||||||
now_secs = (time_t) now / 1000000;
|
now_secs = (time_t) (now / 1000000);
|
||||||
now_tm = localtime (&now_secs);
|
now_tm = localtime (&now_secs);
|
||||||
strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);
|
strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user