summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-11-07 14:29:51 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-11-07 14:31:19 +0100
commit6dcc0b859f5f31729ab3f1e776b067fb338b1978 (patch)
tree342ab968097e8275b2ed8bd01647de4334e24c0d
parent29f4939923e09a548c6bc494da742d97548c62d4 (diff)
downloadphp-git-6dcc0b859f5f31729ab3f1e776b067fb338b1978.tar.gz
Fix php_pcre_mutex_free()
We should only set the mutex to NULL if we actually freed it. Due to missing braces non-main threads may currently set it to NULL first.
-rw-r--r--ext/pcre/php_pcre.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index e82dc252b2..882389e1ce 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -84,8 +84,10 @@ ZEND_TLS zend_bool mdata_used = 0;
ZEND_TLS uint8_t pcre2_init_ok = 0;
#if defined(ZTS) && defined(HAVE_PCRE_JIT_SUPPORT)
static MUTEX_T pcre_mt = NULL;
-#define php_pcre_mutex_alloc() if (tsrm_is_main_thread() && !pcre_mt) pcre_mt = tsrm_mutex_alloc();
-#define php_pcre_mutex_free() if (tsrm_is_main_thread() && pcre_mt) tsrm_mutex_free(pcre_mt); pcre_mt = NULL;
+#define php_pcre_mutex_alloc() \
+ if (tsrm_is_main_thread() && !pcre_mt) pcre_mt = tsrm_mutex_alloc();
+#define php_pcre_mutex_free() \
+ if (tsrm_is_main_thread() && pcre_mt) { tsrm_mutex_free(pcre_mt); pcre_mt = NULL; }
#define php_pcre_mutex_lock() tsrm_mutex_lock(pcre_mt);
#define php_pcre_mutex_unlock() tsrm_mutex_unlock(pcre_mt);
#else