diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 0cb8ed227f8..09a624785a1 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1942,7 +1942,7 @@ docompat: break; } fin: - if (!stayopen && st->db != NULL) { + if (st->db != NULL && !stayopen) { (void)st->db->close(st->db); st->db = NULL; }