summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e6ca3322cb..4623efb3cf 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2263,7 +2263,7 @@ ZEND_METHOD(reflection_parameter, __construct)
case IS_ARRAY: {
zval *classref;
zval *method;
- zend_string *lcname;
+ zend_string *name, *lcname;
if (((classref = zend_hash_index_find(Z_ARRVAL_P(reference), 0)) == NULL)
|| ((method = zend_hash_index_find(Z_ARRVAL_P(reference), 1)) == NULL))
@@ -2275,27 +2275,38 @@ ZEND_METHOD(reflection_parameter, __construct)
if (Z_TYPE_P(classref) == IS_OBJECT) {
ce = Z_OBJCE_P(classref);
} else {
- convert_to_string_ex(classref);
- if ((ce = zend_lookup_class(Z_STR_P(classref))) == NULL) {
+ name = zval_get_string(classref);
+ if (EG(exception)) {
+ return;
+ }
+ if ((ce = zend_lookup_class(name)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", Z_STRVAL_P(classref));
+ "Class %s does not exist", ZSTR_VAL(name));
+ zend_string_release(name);
return;
}
+ zend_string_release(name);
+ }
+
+ name = zval_get_string(method);
+ if (EG(exception)) {
+ return;
}
- convert_to_string_ex(method);
- lcname = zend_string_tolower(Z_STR_P(method));
+ lcname = zend_string_tolower(name);
if (Z_TYPE_P(classref) == IS_OBJECT && is_closure_invoke(ce, lcname)
&& (fptr = zend_get_closure_invoke_method(Z_OBJ_P(classref))) != NULL)
{
/* nothing to do. don't set is_closure since is the invoke handler,
not the closure itself */
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
+ zend_string_release(name);
zend_string_release(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method));
return;
}
+ zend_string_release(name);
zend_string_release(lcname);
}
break;
@@ -2329,29 +2340,23 @@ ZEND_METHOD(reflection_parameter, __construct)
if (Z_TYPE_P(parameter) == IS_LONG) {
position= (int)Z_LVAL_P(parameter);
if (position < 0 || (uint32_t)position >= num_args) {
- if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
- if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- zend_string_release_ex(fptr->common.function_name, 0);
- }
- zend_free_trampoline(fptr);
- }
- if (is_closure) {
- zval_ptr_dtor(reference);
- }
_DO_THROW("The parameter specified by its offset could not be found");
- return;
+ goto failure;
}
} else {
uint32_t i;
- position= -1;
- convert_to_string_ex(parameter);
+ position = -1;
+ if (!try_convert_to_string(parameter)) {
+ goto failure;
+ }
+
if (fptr->type == ZEND_INTERNAL_FUNCTION &&
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
for (i = 0; i < num_args; i++) {
if (arg_info[i].name) {
if (strcmp(((zend_internal_arg_info*)arg_info)[i].name, Z_STRVAL_P(parameter)) == 0) {
- position= i;
+ position = i;
break;
}
@@ -2361,24 +2366,15 @@ ZEND_METHOD(reflection_parameter, __construct)
for (i = 0; i < num_args; i++) {
if (arg_info[i].name) {
if (strcmp(ZSTR_VAL(arg_info[i].name), Z_STRVAL_P(parameter)) == 0) {
- position= i;
+ position = i;
break;
}
}
}
}
if (position == -1) {
- if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
- if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- zend_string_release_ex(fptr->common.function_name, 0);
- }
- zend_free_trampoline(fptr);
- }
- if (is_closure) {
- zval_ptr_dtor(reference);
- }
_DO_THROW("The parameter specified by its name could not be found");
- return;
+ goto failure;
}
}
@@ -2406,6 +2402,18 @@ ZEND_METHOD(reflection_parameter, __construct)
} else {
ZVAL_NULL(prop_name);
}
+ return;
+
+failure:
+ if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
+ if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
+ zend_string_release_ex(fptr->common.function_name, 0);
+ }
+ zend_free_trampoline(fptr);
+ }
+ if (is_closure) {
+ zval_ptr_dtor(reference);
+ }
}
/* }}} */
@@ -3692,7 +3700,10 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
ZVAL_COPY(&intern->obj, argument);
}
} else {
- convert_to_string_ex(argument);
+ if (!try_convert_to_string(argument)) {
+ return;
+ }
+
if ((ce = zend_lookup_class(Z_STR_P(argument))) == NULL) {
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1, "Class %s does not exist", Z_STRVAL_P(argument));