From: Todd C. Miller Date: Tue, 1 Feb 2005 04:03:29 +0000 (+0000) Subject: Don't try to destroy a tree we didn't create. X-Git-Tag: SUDO_1_7_0~732 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=543fe6e7d6d88d8a19bcdc8d97226375039b31e4;p=sudo Don't try to destroy a tree we didn't create. --- diff --git a/pwutil.c b/pwutil.c index 01e72ef70..e4f3895b1 100644 --- a/pwutil.c +++ b/pwutil.c @@ -359,10 +359,14 @@ sudo_endpwent() { endpwent(); sudo_endspent(); - rbdestroy(pwcache_byuid, pw_free); - pwcache_byuid = NULL; - rbdestroy(pwcache_byname, NULL); - pwcache_byname = NULL; + if (pwcache_byuid != NULL) { + rbdestroy(pwcache_byuid, pw_free); + pwcache_byuid = NULL; + } + if (pwcache_byname != NULL) { + rbdestroy(pwcache_byname, NULL); + pwcache_byname = NULL; + } } static void @@ -551,8 +555,12 @@ void sudo_endgrent() { endgrent(); - rbdestroy(grcache_bygid, free); - grcache_bygid = NULL; - rbdestroy(grcache_byname, NULL); - grcache_byname = NULL; + if (grcache_bygid != NULL) { + rbdestroy(grcache_bygid, free); + grcache_bygid = NULL; + } + if (grcache_byname != NULL) { + rbdestroy(grcache_byname, NULL); + grcache_byname = NULL; + } }