# HG changeset patch
# User Alex <alex@linuxonly.ru>
# Date 1558782045 -10800
# Node ID 83553d042443c71be71533b6b91ee10f228d935f
# Parent de113e8953ae708043823578b64882cfc5a45ca2
Fix segfault in strftime_l() because of timestamps from future
diff --git a/src/strformat.c b/src/strformat.c
--- a/src/strformat.c
+++ b/src/strformat.c
@@ -1,7 +1,7 @@
/*
* strformat.c
*
- * Copyright 2013-2014 Alex <alex@linuxonly.ru>
+ * Copyright 2013-2019 Alex <alex@linuxonly.ru>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -182,18 +182,22 @@
memset(buffer, 0, bufsize);
- if (delta <= 0.0) {
- if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) {
- g_snprintf(buffer, bufsize, _("Unknown"));
- }
- } else if ((delta > 0.0) && (delta < 86400.0)) {
- if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) {
- g_snprintf(buffer, bufsize, _("Unknown"));
+ if (ftime != NULL) {
+ if (delta <= 0.0) {
+ if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) {
+ g_snprintf(buffer, bufsize, _("Unknown"));
+ }
+ } else if ((delta > 0.0) && (delta < 86400.0)) {
+ if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) {
+ g_snprintf(buffer, bufsize, _("Unknown"));
+ }
+ } else {
+ if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) {
+ g_snprintf(buffer, bufsize, _("Unknown"));
+ }
}
} else {
- if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) {
- g_snprintf(buffer, bufsize, _("Unknown"));
- }
+ g_snprintf(buffer, bufsize, _("Unknown"));
}
return buffer;