From 3a04adce828767af8204dc106ed7b8d0f261150a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 18 Apr 2019 14:26:15 +0300 Subject: [PATCH] Check assert only when RC_DEBUG is enabled --- Zend/zend_string.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 0aa6665c19..61e5f51b7f 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -234,7 +234,13 @@ static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string * } /* Create a short living interned, freed after the request. */ - ZEND_ASSERT(!(GC_FLAGS(str) & GC_PERSISTENT)); +#if ZEND_RC_DEBUG + if (zend_rc_debug) { + /* PHP shouldn't create persistent interned string during request, + * but at least dl() may do this */ + ZEND_ASSERT(!(GC_FLAGS(str) & GC_PERSISTENT)); + } +#endif if (GC_REFCOUNT(str) > 1) { zend_ulong h = ZSTR_H(str); zend_string_delref(str); @@ -257,6 +263,7 @@ static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char return ret; } + ZEND_ASSERT(permanent); ret = zend_string_init(str, size, permanent); ZSTR_H(ret) = h; return zend_add_interned_string(ret, &interned_strings_permanent, IS_STR_PERMANENT); @@ -278,6 +285,13 @@ static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char * return ret; } +#if ZEND_RC_DEBUG + if (zend_rc_debug) { + /* PHP shouldn't create persistent interned string during request, + * but at least dl() may do this */ + ZEND_ASSERT(!permanent); + } +#endif ret = zend_string_init(str, size, permanent); ZSTR_H(ret) = h; -- 2.40.0