[planner] Avoid an access violation caused by freeing memory given through putenv.



commit c6af975a48b549b2a95beb5cfae344d45ec1976f
Author: Luis Menina <liberforce freeside fr>
Date:   Fri Mar 8 22:55:41 2013 +0100

    Avoid an access violation caused by freeing memory given through putenv.
    
    Strings given to the environment through putenv can't be freed as long
    as they are used by the environment. g_setenv doesn't have this problem.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=655461

 libplanner/mrp-time.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/libplanner/mrp-time.c b/libplanner/mrp-time.c
index 1501076..f07b883 100644
--- a/libplanner/mrp-time.c
+++ b/libplanner/mrp-time.c
@@ -164,8 +164,10 @@ mrp_time_debug_print (mrptime t)
 mrptime
 mrp_time_from_tm (struct tm *tm)
 {
+       /* A portable implementation is available in the notes of the man page
+        * for timegm */
+
        gchar   *old_tz;
-       gchar   *tmp;
        mrptime  t;
 
        /* This is a hack. Set the timezone to UTC temporarily. */
@@ -176,9 +178,7 @@ mrp_time_from_tm (struct tm *tm)
 
        /* And set it back. */
        if (old_tz != NULL && old_tz[0] != '\0') {
-               tmp = g_strconcat ("TZ=", old_tz, NULL);
-               putenv (tmp);
-               g_free (tmp);
+               g_setenv ("TZ", old_tz, TRUE);
        } else {
                g_unsetenv ("TZ");
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]