Skip to content

Commit 03f97fc

Browse files
authored
Avoid unnecessary string refcounting in ext/pcre (#17893)
1 parent 1eacd4a commit 03f97fc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/pcre/php_pcre.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,9 +1563,12 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
15631563
fci->params = &arg;
15641564
zend_call_function(fci, fcc);
15651565
zval_ptr_dtor(&arg);
1566+
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
1567+
return Z_STR(retval);
1568+
}
15661569
/* No Exception has occurred */
1567-
if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) {
1568-
result_str = zval_try_get_string(&retval);
1570+
else if (EXPECTED(Z_TYPE(retval) != IS_UNDEF)) {
1571+
result_str = zval_try_get_string_func(&retval);
15691572
}
15701573
zval_ptr_dtor(&retval);
15711574

0 commit comments

Comments
 (0)