Skip to content

Commit 6dcc0b8

Browse files
committed
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.
1 parent 29f4939 commit 6dcc0b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/pcre/php_pcre.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ ZEND_TLS zend_bool mdata_used = 0;
8484
ZEND_TLS uint8_t pcre2_init_ok = 0;
8585
#if defined(ZTS) && defined(HAVE_PCRE_JIT_SUPPORT)
8686
static MUTEX_T pcre_mt = NULL;
87-
#define php_pcre_mutex_alloc() if (tsrm_is_main_thread() && !pcre_mt) pcre_mt = tsrm_mutex_alloc();
88-
#define php_pcre_mutex_free() if (tsrm_is_main_thread() && pcre_mt) tsrm_mutex_free(pcre_mt); pcre_mt = NULL;
87+
#define php_pcre_mutex_alloc() \
88+
if (tsrm_is_main_thread() && !pcre_mt) pcre_mt = tsrm_mutex_alloc();
89+
#define php_pcre_mutex_free() \
90+
if (tsrm_is_main_thread() && pcre_mt) { tsrm_mutex_free(pcre_mt); pcre_mt = NULL; }
8991
#define php_pcre_mutex_lock() tsrm_mutex_lock(pcre_mt);
9092
#define php_pcre_mutex_unlock() tsrm_mutex_unlock(pcre_mt);
9193
#else

0 commit comments

Comments
 (0)