diff -r bbca8e94fa67 -r 5c31cc844c68 src/server/daemon/webserver.c
--- a/src/server/daemon/webserver.c	Fri Jan 31 21:01:48 2025 +0100
+++ b/src/server/daemon/webserver.c	Fri Jan 31 21:27:54 2025 +0100
@@ -68,6 +68,8 @@
 
 static RestartCallback *atrestart;
 
+static char *pwbuf;
+
 int webserver_init() { 
     // init NSPR
     systhread_init("webserver");
@@ -126,7 +128,7 @@
     WSBool changeuid = FALSE;
     uid_t ws_uid = geteuid();
     setpwent();
-    char *pwbuf = malloc(DEF_PWBUF);
+    pwbuf = malloc(DEF_PWBUF);
     vars->Vuserpw = malloc(sizeof(struct passwd));
     if(cfg->user.ptr) {
         if(!util_getpwnam(cfg->user.ptr, vars->Vuserpw, pwbuf, DEF_PWBUF)) {
@@ -149,6 +151,7 @@
     if(!vars->Vuserpw) {
         log_ereport(LOG_VERBOSE, "globalvars->Vuserpw is null");
     }
+    endpwent();
     
     // change uid
     if(changeuid && ws_uid == 0) {
@@ -350,7 +353,13 @@
     func_cleanup();
     
     ServerConfiguration *scfg = cfgmgr_get_server_config();
+    CxIterator i = cxListIterator(scfg->logfiles);
+    cx_foreach(AccessLog *, logfile, i) {
+        fclose(logfile->log->file);
+    }
     pool_destroy(scfg->pool);
+    
+    free(pwbuf);
 }
 
 int nsapi_runtime_version() {