From 03c34cc73fe417f31cbecf51f5895d24ae13924d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 8 Jan 2020 16:01:51 +0100 Subject: [PATCH] LibC: Don't leave /etc/passwd open in getlogin() --- Libraries/LibC/unistd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 7a48eff5d7..a4c6c6234a 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -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; }