]> granicus.if.org Git - php/commitdiff
Fix mbstring overloads in zts
authorNikita Popov <nikic@php.net>
Tue, 26 Aug 2014 22:53:24 +0000 (00:53 +0200)
committerNikita Popov <nikic@php.net>
Tue, 26 Aug 2014 23:26:57 +0000 (01:26 +0200)
ext/mbstring/mbstring.c

index db8f352aa8a0992eb81b98a1de273931fd1ba9ba..c82e4f483e511e9f61ed96cfdd3db8286d5b5f7a 100644 (file)
@@ -1622,9 +1622,8 @@ PHP_RINIT_FUNCTION(mbstring)
                CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
                while (p->type > 0) {
                        if ((MBSTRG(func_overload) & p->type) == p->type && 
-                               (orig = zend_hash_str_find_ptr(EG(function_table), p->save_func,
-                                       strlen(p->save_func))) == NULL) {
-
+                               !zend_hash_str_exists(EG(function_table), p->save_func, strlen(p->save_func))
+                       ) {
                                func = zend_hash_str_find_ptr(EG(function_table), p->ovld_func, strlen(p->ovld_func));
                                
                                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)
                                } else {
                                        ZEND_ASSERT(orig->type == ZEND_INTERNAL_FUNCTION);
                                        zend_hash_str_add_mem(EG(function_table), p->save_func, strlen(p->save_func), orig, sizeof(zend_internal_function));
+                                       function_add_ref(orig);
 
                                        if (zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), func, sizeof(zend_internal_function)) == NULL) {
                                                php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func);
                                                return FAILURE;
                                        }
+
+                                       function_add_ref(func);
                                }
                        }
                        p++;
@@ -1684,6 +1686,7 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
                                (orig = zend_hash_str_find_ptr(EG(function_table), p->save_func, strlen(p->save_func)))) {
                                
                                zend_hash_str_update_mem(EG(function_table), p->orig_func, strlen(p->orig_func), orig, sizeof(zend_internal_function));
+                               function_add_ref(orig);
                                zend_hash_str_del(EG(function_table), p->save_func, strlen(p->save_func));
                        }
                        p++;