]> git.webhop.me Git - lcd4linux.git/commitdiff
strftime_tz patch from Bernhard Walle
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 14 Sep 2008 04:00:49 +0000 (04:00 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 14 Sep 2008 04:00:49 +0000 (04:00 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@894 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_time.c

index bae321c0b4393eebc493bd6d1ce9072e3f35f17e..a9cca8f086fd2e2716228a7260a4db2a912c0a8e 100644 (file)
@@ -68,6 +68,15 @@ static void my_stftime_tz(RESULT * result, RESULT * arg1, RESULT * arg2, RESULT
     char *old_tz;
 
     old_tz = getenv("TZ");
+
+    /*
+     * because the next setenv() call may overwrite that string, we
+     * duplicate it here
+     */
+    if (old_tz) {
+       old_tz = strdup(old_tz);
+    }
+
     setenv("TZ", tz, 1);
     tzset();
 
@@ -80,6 +89,8 @@ static void my_stftime_tz(RESULT * result, RESULT * arg1, RESULT * arg2, RESULT
     }
     tzset();
 
+    free(old_tz);
+
     SetResult(&result, R_STRING, value);
 }