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 Dec 11, 2024
1 parent 3abc9fb commit 52615ec
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 char* user_env = g_strdup_printf ("USER=%s", username);
pam_putenv (pam_handle, user_env);
g_autofree char* logname_env = g_strdup_printf ("LOGNAME=%s", username);
pam_putenv (pam_handle, logname_env);
g_autofree char* home_env = g_strdup_printf ("HOME=%s",user_get_home_directory (user));
pam_putenv (pam_handle, home_env);
g_autofree char* 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 52615ec

Please sign in to comment.