]> granicus.if.org Git - php/commitdiff
Fix php_pcre_mutex_free()
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 7 Nov 2019 13:29:51 +0000 (14:29 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 7 Nov 2019 13:31:19 +0000 (14:31 +0100)
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.

ext/pcre/php_pcre.c

index e82dc252b2742dcf5cb6bb50d27f144e2a6d9cde..882389e1cef18134ccf040d4707a28ad07fa1108 100644 (file)
@@ -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