Fix segfaults on restart when pcre_{malloc,free} get left pointing at random bits of memory after PHP is unloaded. Global variables: Just Don't Do It. --- php-4.3.6/ext/pcre/php_pcre.c.pcrealloc +++ php-4.3.6/ext/pcre/php_pcre.c @@ -47,7 +47,7 @@ ZEND_DECLARE_MODULE_GLOBALS(pcre) - +#if 0 static void *php_pcre_malloc(size_t size) { return pemalloc(size, 1); @@ -59,7 +59,7 @@ if (ptr) pefree(ptr, 1); } - +#endif static void php_free_pcre_cache(void *data) { @@ -107,8 +107,10 @@ REGISTER_LONG_CONSTANT("PREG_SPLIT_OFFSET_CAPTURE", PREG_SPLIT_OFFSET_CAPTURE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PREG_GREP_INVERT", PREG_GREP_INVERT, CONST_CS | CONST_PERSISTENT); +#if 0 pcre_malloc = php_pcre_malloc; pcre_free = php_pcre_free; +#endif #ifdef NO_RECURSE pcre_stack_malloc = php_pcre_malloc; @@ -548,7 +550,7 @@ } } - php_pcre_free((void *) stringlist); + pcre_free((void *) stringlist); } } else { /* Failed to match */