Fix a bug that incorrectly uses putenv 82/265882/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211109.041749 submit/tizen_6.5/20211108.033656
authorINSUN PYO <insun.pyo@samsung.com>
Fri, 23 Oct 2020 01:15:15 +0000 (10:15 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Mon, 1 Nov 2021 08:20:39 +0000 (08:20 +0000)
Refer: https://stackoverflow.com/questions/5873029/questions-about-putenv-and-setenv

Change-Id: I26f1e7e6ce14f78f827a8440b97baf930b6d3102
(cherry picked from commit 43c2e3bbc25b77ab7f9d56956fc855a4f4b13788)

src/sessiond/tlm-session.c

index 15cc0a7..af75296 100755 (executable)
@@ -423,7 +423,7 @@ reset_exit:
 static gboolean
 _set_environment (TlmSessionPrivate *priv)
 {
-       gchar **envlist = tlm_auth_session_get_envlist(priv->auth_session);
+    gchar **envlist = tlm_auth_session_get_envlist(priv->auth_session);
     gchar *home_dir = NULL, *shell = NULL;
 
     if (envlist) {
@@ -431,7 +431,7 @@ _set_environment (TlmSessionPrivate *priv)
         for (env = envlist; *env != NULL; ++env) {
             DBG ("ENV : %s", *env);
             putenv(*env);
-            g_free (*env);
+            // Don't free *env because putenv uses pointer internally without copying the string.
         }
         g_free (envlist);
     }