1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibC: Don't leave /etc/passwd open in getlogin()

This commit is contained in:
Andreas Kling 2020-01-08 16:01:51 +01:00
parent e1d4b19461
commit 03c34cc73f

View file

@ -516,8 +516,10 @@ char* getlogin()
static char __getlogin_buffer[256];
if (auto* passwd = getpwuid(getuid())) {
strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer));
endpwent();
return __getlogin_buffer;
}
endpwent();
return nullptr;
}