summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/pwd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibC/pwd.cpp')
-rw-r--r--Userland/Libraries/LibC/pwd.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/pwd.cpp b/Userland/Libraries/LibC/pwd.cpp
index b13e4b3db7..3d9ffcb156 100644
--- a/Userland/Libraries/LibC/pwd.cpp
+++ b/Userland/Libraries/LibC/pwd.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/TemporaryChange.h>
#include <AK/Vector.h>
@@ -51,6 +52,7 @@ void endpwent()
struct passwd* getpwuid(uid_t uid)
{
setpwent();
+ ScopeGuard guard = [] { endpwent(); };
while (auto* pw = getpwent()) {
if (pw->pw_uid == uid)
return pw;
@@ -61,6 +63,7 @@ struct passwd* getpwuid(uid_t uid)
struct passwd* getpwnam(char const* name)
{
setpwent();
+ ScopeGuard guard = [] { endpwent(); };
while (auto* pw = getpwent()) {
if (!strcmp(pw->pw_name, name))
return pw;