nwrap: Don't leak memory from gethostbyname*() functions
[obnox/samba/samba-obnox.git] / lib / nss_wrapper / nss_wrapper.c
index 562efba251509114fab02304579957f96c005381..be977dfad96c138fb3b7500e22ae9a076234a7c2 100644 (file)
@@ -5551,6 +5551,20 @@ void nwrap_destructor(void)
                nwrap_pw_global.num = 0;
        }
 
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
+       if (nwrap_sp_global.cache != NULL) {
+               struct nwrap_cache *c = nwrap_sp_global.cache;
+
+               nwrap_files_cache_unload(c);
+               if (c->fd >= 0) {
+                       fclose(c->fp);
+                       c->fd = -1;
+               }
+
+               nwrap_sp_global.num = 0;
+       }
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
+
        if (nwrap_he_global.cache != NULL) {
                struct nwrap_cache *c = nwrap_he_global.cache;
 
@@ -5563,6 +5577,9 @@ void nwrap_destructor(void)
                nwrap_he_global.num = 0;
        }
 
+       free(user_addrlist.items);
+       free(user_addrlist2.items);
+
        hdestroy();
        NWRAP_UNLOCK_ALL;
 }