[Xfce4-commits] [panel-plugins/xfce4-weather-plugin] 01/01: Fix showing times in UTC instead of local time on FreeBSD (bug #13358)

noreply at xfce.org noreply at xfce.org
Tue Apr 25 12:31:06 CEST 2017


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository panel-plugins/xfce4-weather-plugin.

commit 701222e668699b192f7109d917851c69f4e6efb8
Author: Alexander Zagrebin <alex at zagrebin.ru>
Date:   Tue Apr 25 11:23:52 2017 +0200

    Fix showing times in UTC instead of local time on FreeBSD (bug #13358)
    
    I've noticed, that the xfce4-weather-plugin always shows local times in UTC
    instead of my local timezone.
    
    The reason is in function my_timegm() (weather-parsers.c).
    This function attempts to keep a current timezone, obtained with a call to
    g_getenv(), changes a timezone to UTC via g_setenv(), and then restores a
    current timezone to early saved one.
    
    But at least on FreeBSD there is a problem:
    g_getenv returns a pointer to the area, where system stores the environment.
    So my_timegm() keeps for a later use a pointer to current value of the TZ
    environment variable. A subsequent call to g_setenv() changes value of the
    TZ variable in-place, so now the saved pointer refers to a value which was
    set by g_setenv(), but not to a previous timezone. As result an attempt to
    restore current timezone does nothing.
    
    This commit fixes this.
---
 panel-plugin/weather-parsers.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index 74a05a6..bec10f7 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -54,14 +54,16 @@ static time_t
 my_timegm(struct tm *tm)
 {
     time_t ret;
-    const char *tz;
+    char *tz;
 
-    tz = g_getenv("TZ");
+    tz = g_strdup(g_getenv("TZ"));
     g_setenv("TZ", "", 1);
     tzset();
     ret = mktime(tm);
-    if (tz)
+    if (tz) {
         g_setenv("TZ", tz, 1);
+        g_free(tz);
+    }
     else
         g_unsetenv("TZ");
     tzset();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list