From 3d8cc07c5af283289f62f0964f153804f2cc1862 Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Fri, 4 Mar 2016 11:34:33 +0100 Subject: fixed ZTS segfault (closes #4) --- php_suhosin7.h | 13 +++++++------ suhosin7.c | 14 ++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/php_suhosin7.h b/php_suhosin7.h index 5024790..cbde402 100644 --- a/php_suhosin7.h +++ b/php_suhosin7.h @@ -37,6 +37,9 @@ extern zend_module_entry suhosin7_module_entry; # define SUHOSIN7_API #endif +#ifdef ZTS +#include "TSRM.h" +#endif /* -------------- */ @@ -323,12 +326,12 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) ZEND_END_MODULE_GLOBALS(suhosin7) -/* Always refer to the globals in your function as SUHOSIN7_G(variable). - You are encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ #define SUHOSIN7_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(suhosin7, v) +#if defined(ZTS) && defined(COMPILE_DL_SUHOSIN7) +ZEND_TSRMLS_CACHE_EXTERN(); +#endif + /* Error Constants */ #ifndef S_MEMORY @@ -417,8 +420,6 @@ char *suhosin_strcasestr(char *haystack, char *needle) #define suhosin_strcasestr(a, b) strcasestr(a, b) #endif -/* {{{ suhosin_strcasestr */ - /* * Local variables: diff --git a/suhosin7.c b/suhosin7.c index 42a058f..14b7fa0 100644 --- a/suhosin7.c +++ b/suhosin7.c @@ -27,17 +27,14 @@ #include "php.h" #include "php_ini.h" #include "SAPI.h" -#include "php_suhosin7.h" #include "suhosin7_logo.h" #include "ext/standard/base64.h" #include "ext/standard/info.h" +#include "php_suhosin7.h" ZEND_DECLARE_MODULE_GLOBALS(suhosin7) -/* True global resources - no need for thread safety here */ -// static int le_suhosin7; - /* ------------------------------------------------------------------------ */ /* PERDIR CHECKS */ #define PERDIR_CHECK(lower) \ @@ -449,6 +446,11 @@ char *suhosin_getenv(char *name, size_t name_len) */ static void php_suhosin7_init_globals(zend_suhosin7_globals *suhosin7_globals) { + SDEBUG("."); +#if defined(COMPILE_DL_SUHOSIN7) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif + memset(suhosin7_globals, 0, sizeof(zend_suhosin7_globals)); } /* }}} */ @@ -540,6 +542,10 @@ PHP_MSHUTDOWN_FUNCTION(suhosin7) PHP_RINIT_FUNCTION(suhosin7) { SDEBUG("(RINIT)"); +#if defined(COMPILE_DL_SUHOSIN7) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif + SUHOSIN7_G(in_code_type) = SUHOSIN_NORMAL; SUHOSIN7_G(execution_depth) = 0; -- cgit v1.3