When adding new groups, putgrent_with_members() is called with the newly constructed group n, but the error path logs gr->gr_name. gr belongs to the earlier loop over the existing group file and may be NULL after EOF. Log n.gr_name instead. Found by Linux Verification Center (linuxtesting.org) with Svace.