From eac0b2e98f58351c8062536d39c36b4d1ac7c9a6 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 23 Jan 2017 14:54:58 +0300 Subject: [PATCH] Check for old style constructor only if method is not found --- Zend/zend_object_handlers.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 6e0b9d4428..109f442046 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1257,21 +1257,19 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st lc_function_name = zend_string_tolower(function_name); } - if (ZSTR_LEN(function_name) == ZSTR_LEN(ce->name) && ce->constructor) { - lc_class_name = zend_str_tolower_dup(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name)); - /* Only change the method to the constructor if the constructor isn't called __construct - * we check for __ so we can be binary safe for lowering, we should use ZEND_CONSTRUCTOR_FUNC_NAME - */ - if (!memcmp(lc_class_name, ZSTR_VAL(lc_function_name), ZSTR_LEN(function_name)) && memcmp(ZSTR_VAL(ce->constructor->common.function_name), "__", sizeof("__") - 1)) { - fbc = ce->constructor; - } - efree(lc_class_name); - } - - if (EXPECTED(!fbc)) { + do { zval *func = zend_hash_find(&ce->function_table, lc_function_name); if (EXPECTED(func != NULL)) { fbc = Z_FUNC_P(func); + } else if (ce->constructor + && ZSTR_LEN(lc_function_name) == ZSTR_LEN(ce->name) + && zend_binary_strncasecmp(ZSTR_VAL(lc_function_name), ZSTR_LEN(lc_function_name), ZSTR_VAL(ce->name), ZSTR_LEN(lc_function_name), ZSTR_LEN(lc_function_name)) == 0 + /* Only change the method to the constructor if the constructor isn't called __construct + * we check for __ so we can be binary safe for lowering, we should use ZEND_CONSTRUCTOR_FUNC_NAME + */ + && (ZSTR_VAL(ce->constructor->common.function_name)[0] != '_' + || ZSTR_VAL(ce->constructor->common.function_name)[1] != '_')) { + fbc = ce->constructor; } else { if (UNEXPECTED(!key)) { zend_string_release(lc_function_name); @@ -1294,7 +1292,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st return NULL; } } - } + } while (0); #if MBO_0 /* right now this function is used for non static method lookup too */ -- 2.40.0