Browse Source

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

Andreas Kling 5 years ago
parent
commit
03c34cc73f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Libraries/LibC/unistd.cpp

+ 2 - 0
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;
 }