Fix a bug that incorrectly uses putenv 67/246167/1 tizen_5.5
authorINSUN PYO <insun.pyo@samsung.com>
Fri, 23 Oct 2020 01:15:15 +0000 (10:15 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 26 Oct 2020 08:02:47 +0000 (08:02 +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 7c8c08c044953a7313d2b663696d45207ff719d3..7782aa11dbd1c36e1c351fd1b58ffb70959c0bb1 100755 (executable)
@@ -428,7 +428,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) {
@@ -436,7 +436,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);
     }