Memory leak in msc_pregcomp_ex
apr_pool_cleanup_register() is called at the very end of the function. In case any problem occurs (e.g., regex cannot compile) we return immediately, so the cleanup is never performed.
apr_pool_cleanup_register() should be called right after calling pcre_compile() to cleanup memory allocated by pcre.
@marcstern Please mention the code part here.
Usually when a regex is not compiled ModSecurity failed to start, the process die and the kernel will free-up the memory resources. Whats leads you to believe that this is an issue?
There's one case where we return before cleaning up. It's in case of a memory allocation problem, so it should hopefully not happen often. However, in the case we add another test in the middle (and we should probably add one with the fix https://github.com/SpiderLabs/ModSecurity/issues/610), we'll introduce a memory leak.