com php-src: Fix php_pcre_mutex_free(): ext/pcre/ php_pcre.c
| From: | Nikita Popov | Date: | Thu, 07 Nov 2019 13:31:19 +0000 |
| Subject: | com php-src: Fix php_pcre_mutex_free(): ext/pcre/ php_pcre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-109209@lists.php.net to get a copy of this message | ||
Commit: 6dcc0b859f5f31729ab3f1e776b067fb338b1978
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 7 Nov 2019 14:29:51 +0100
Parents: 29f4939923e09a548c6bc494da742d97548c62d4
Branches: PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6dcc0b859f5f31729ab3f1e776b067fb338b1978
Log:
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.
Changed paths:
M ext/pcre/php_pcre.c
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index e82dc252b27..882389e1cef 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