Skip to content

Commit f719b9d

Browse files
committed
Fix mbstring overloads in zts
1 parent 2788a71 commit f719b9d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: ext/mbstring/mbstring.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -1622,9 +1622,8 @@ PHP_RINIT_FUNCTION(mbstring)
16221622
CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
16231623
while (p->type > 0) {
16241624
if ((MBSTRG(func_overload) & p->type) == p->type &&
1625-
(orig = zend_hash_str_find_ptr(EG(function_table), p->save_func,
1626-
strlen(p->save_func))) == NULL) {
1627-
1625+
!zend_hash_str_exists(EG(function_table), p->save_func, strlen(p->save_func))
1626+
) {
16281627
func = zend_hash_str_find_ptr(EG(function_table), p->ovld_func, strlen(p->ovld_func));
16291628

16301629
if ((orig = zend_hash_str_find_ptr(EG(function_table), p->orig_func, strlen(p->orig_func))) == NULL) {
@@ -1633,11 +1632,14 @@ PHP_RINIT_FUNCTION(mbstring)
16331632
} else {
16341633
ZEND_ASSERT(orig->type == ZEND_INTERNAL_FUNCTION);
16351634
zend_hash_str_add_mem(EG(function_table), p->save_func, strlen(p->save_func), orig, sizeof(zend_internal_function));
1635+
function_add_ref(orig);
16361636

16371637
if (zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), func, sizeof(zend_internal_function)) == NULL) {
16381638
php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func);
16391639
return FAILURE;
16401640
}
1641+
1642+
function_add_ref(func);
16411643
}
16421644
}
16431645
p++;
@@ -1684,6 +1686,7 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
16841686
(orig = zend_hash_str_find_ptr(EG(function_table), p->save_func, strlen(p->save_func)))) {
16851687

16861688
zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), orig, sizeof(zend_internal_function));
1689+
function_add_ref(orig);
16871690
zend_hash_str_del(EG(function_table), p->save_func, strlen(p->save_func));
16881691
}
16891692
p++;

0 commit comments

Comments
 (0)