Skip to content

Commit 3a04adc

Browse files
committed
Check assert only when RC_DEBUG is enabled
1 parent b2f49c6 commit 3a04adc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Zend/zend_string.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string *
234234
}
235235

236236
/* Create a short living interned, freed after the request. */
237-
ZEND_ASSERT(!(GC_FLAGS(str) & GC_PERSISTENT));
237+
#if ZEND_RC_DEBUG
238+
if (zend_rc_debug) {
239+
/* PHP shouldn't create persistent interned string during request,
240+
* but at least dl() may do this */
241+
ZEND_ASSERT(!(GC_FLAGS(str) & GC_PERSISTENT));
242+
}
243+
#endif
238244
if (GC_REFCOUNT(str) > 1) {
239245
zend_ulong h = ZSTR_H(str);
240246
zend_string_delref(str);
@@ -257,6 +263,7 @@ static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char
257263
return ret;
258264
}
259265

266+
ZEND_ASSERT(permanent);
260267
ret = zend_string_init(str, size, permanent);
261268
ZSTR_H(ret) = h;
262269
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 *
278285
return ret;
279286
}
280287

288+
#if ZEND_RC_DEBUG
289+
if (zend_rc_debug) {
290+
/* PHP shouldn't create persistent interned string during request,
291+
* but at least dl() may do this */
292+
ZEND_ASSERT(!permanent);
293+
}
294+
#endif
281295
ret = zend_string_init(str, size, permanent);
282296
ZSTR_H(ret) = h;
283297

0 commit comments

Comments
 (0)