Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix some memory leak in session_child_run #385

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

KT-lcz
Copy link
Contributor

@KT-lcz KT-lcz commented Dec 11, 2024

The memory requested using g_strdup_printf is not released. Use g_autofree to release the memory.

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency char -> gchar, but otherwise everything looks great! Looks like putenv requires the string to remain, but pam_putenv makes a copy which is why this leak was probably added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks you,I will correct the ‘char‘ to ‘gchar‘

The memory requested using g_strdup_printf is not released. Use g_autofree to release the memory.
@KT-lcz KT-lcz requested a review from robert-ancell December 12, 2024 02:02
@robert-ancell robert-ancell merged commit f043bfd into canonical:main Dec 12, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants