aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index f9ebba5a..0ddae386 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -3175,11 +3175,14 @@ time_t remote_tzoffset_sec(const gchar *zone)
time_t tzoffset_sec(time_t *now)
{
- struct tm gmt, *lt;
+ struct tm gmt, *tmp, *lt;
gint off;
- gmt = *gmtime(now);
+ tmp = gmtime(now);
+ g_return_val_if_fail(tmp != NULL, -1);
+ gmt = *tmp;
lt = localtime(now);
+ g_return_val_if_fail(lt != NULL, -1);
off = (lt->tm_hour - gmt.tm_hour) * 60 + lt->tm_min - gmt.tm_min;
@@ -3204,12 +3207,15 @@ time_t tzoffset_sec(time_t *now)
gchar *tzoffset(time_t *now)
{
static gchar offset_string[6];
- struct tm gmt, *lt;
+ struct tm gmt, *tmp, *lt;
gint off;
gchar sign = '+';
- gmt = *gmtime(now);
+ tmp = gmtime(now);
+ g_return_val_if_fail(tmp != NULL, NULL);
+ gmt = *tmp;
lt = localtime(now);
+ g_return_val_if_fail(lt != NULL, NULL);
off = (lt->tm_hour - gmt.tm_hour) * 60 + lt->tm_min - gmt.tm_min;