]> granicus.if.org Git - sudo/commitdiff
Don't try to destroy a tree we didn't create.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Feb 2005 04:03:29 +0000 (04:03 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Feb 2005 04:03:29 +0000 (04:03 +0000)
pwutil.c

index 01e72ef70dc7fdb7e760527856526e5e71663256..e4f3895b18aa4abee39021cf05f97e06d4b776d4 100644 (file)
--- 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;
+    }
 }