* modules/generators/mod_cgid.c (cgid_server): Register cleanup for
socket earlier to avoid possible leaks on error paths.  (highlighted
by Coverity scan)
@@ -744,6 +744,9 @@ static int cgid_server(void *data)
return errno;
}
+ apr_pool_cleanup_register(pcgi, (void *)((long)sd),
+ close_unix_socket, close_unix_socket);
+
omask = umask(0077); /* so that only Apache can use socket */
rc = bind(sd, (struct sockaddr *)server_addr, server_addr_len);
umask(omask); /* can't fail, so can't clobber errno */
@@ -778,9 +781,6 @@ static int cgid_server(void *data)
}
}
- apr_pool_cleanup_register(pcgi, (void *)((long)sd),
- close_unix_socket, close_unix_socket);
-
/* if running as root, switch to configured user/group */
if ((rc = ap_run_drop_privileges(pcgi, ap_server_conf)) != 0) {
return rc;
