Skip to content

Commit

Permalink
fix: fix some memory leak in session_child_run
Browse files Browse the repository at this point in the history
The memory requested using g_strdup_printf is not released. Use g_autofree to release the memory.
  • Loading branch information
KT-lcz authored and lichangze committed Dec 12, 2024
1 parent 3abc9fb commit 1a7f9ee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/session-child.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,14 @@ session_child_run (int argc, char **argv)
{
/* Set POSIX variables */
pam_putenv (pam_handle, "PATH=/usr/local/bin:/usr/bin:/bin");
pam_putenv (pam_handle, g_strdup_printf ("USER=%s", username));
pam_putenv (pam_handle, g_strdup_printf ("LOGNAME=%s", username));
pam_putenv (pam_handle, g_strdup_printf ("HOME=%s", user_get_home_directory (user)));
pam_putenv (pam_handle, g_strdup_printf ("SHELL=%s", user_get_shell (user)));
g_autofree gchar* user_env = g_strdup_printf ("USER=%s", username);
pam_putenv (pam_handle, user_env);
g_autofree gchar* logname_env = g_strdup_printf ("LOGNAME=%s", username);
pam_putenv (pam_handle, logname_env);
g_autofree gchar* home_env = g_strdup_printf ("HOME=%s",user_get_home_directory (user));
pam_putenv (pam_handle, home_env);
g_autofree gchar* shell_env = g_strdup_printf ("SHELL=%s", user_get_shell (user));
pam_putenv (pam_handle, shell_env);

/* Let the greeter and user session inherit the system default locale */
static const gchar * const locale_var_names[] = {
Expand Down

0 comments on commit 1a7f9ee

Please sign in to comment.