[glib/glib-2-70: 12/18] gmessages: Add check for a localtime function return value
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-70: 12/18] gmessages: Add check for a localtime function return value
- Date: Tue, 19 Oct 2021 06:21:26 +0000 (UTC)
commit 644c9b964d26f15a90221fe6f090b84f78133841
Author: Egor Bychin <e bychin drweb com>
Date: Mon Oct 11 14:10:39 2021 +0300
gmessages: Add check for a localtime function return value
glib/gmessages.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 890751297..7affcd4d9 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -2321,7 +2321,10 @@ g_log_writer_format_fields (GLogLevelFlags log_level,
now = g_get_real_time ();
now_secs = (time_t) (now / 1000000);
now_tm = localtime (&now_secs);
- strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);
+ if (G_LIKELY (now_tm != NULL))
+ strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);
+ else
+ strcpy (time_buf, "(error)");
g_string_append_printf (gstring, "%s%s.%03d%s: ",
use_color ? "\033[34m" : "",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]