1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# 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;
|