]> granicus.if.org Git - php/commitdiff
Assert that arginfo parameter name is present
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Apr 2020 14:05:33 +0000 (16:05 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Apr 2020 14:05:33 +0000 (16:05 +0200)
Zend/zend_API.c
Zend/zend_inheritance.c
ext/reflection/php_reflection.c

index 68bee582c11b333b5fbb06f866b75abbb065e68e..47730ff3ed9cbf40e7ff2675e49d6cbe3fd71dc7 100644 (file)
@@ -2167,9 +2167,10 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
                if (reg_function->common.arg_info && reg_function->common.num_args) {
                        uint32_t i;
                        for (i = 0; i < reg_function->common.num_args; i++) {
-                               if (ZEND_TYPE_IS_SET(reg_function->common.arg_info[i].type)) {
+                               zend_arg_info *arg_info = &reg_function->common.arg_info[i];
+                               ZEND_ASSERT(arg_info->name && "Parameter must have a name");
+                               if (ZEND_TYPE_IS_SET(arg_info->type)) {
                                    reg_function->common.fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
-                                       break;
                                }
                        }
                }
index ad02380e35698bde12bdb1e1a1fa89e544874721..10e8552b69f1f4e9fd343d1f08e3cd54fd8f70ba 100644 (file)
@@ -670,16 +670,10 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function
                        }
 
                        smart_str_appendc(&str, '$');
-
-                       if (arg_info->name) {
-                               if (fptr->type == ZEND_INTERNAL_FUNCTION) {
-                                       smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
-                               } else {
-                                       smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
-                               }
+                       if (fptr->type == ZEND_INTERNAL_FUNCTION) {
+                               smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
                        } else {
-                               smart_str_appends(&str, "param");
-                               smart_str_append_unsigned(&str, i);
+                               smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
                        }
 
                        if (i >= required && !ZEND_ARG_IS_VARIADIC(arg_info)) {
index 278e565874ddaa08019beffd28a5e41d4d8c1161..e9993e9feb2ac27b30161000404bef7b747c0b6e 100644 (file)
@@ -638,15 +638,12 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
        if (ZEND_ARG_IS_VARIADIC(arg_info)) {
                smart_str_appends(str, "...");
        }
-       if (arg_info->name) {
-               smart_str_append_printf(str, "$%s",
-                       (fptr->type == ZEND_INTERNAL_FUNCTION &&
-                        !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
-                       ((zend_internal_arg_info*)arg_info)->name :
-                       ZSTR_VAL(arg_info->name));
-       } else {
-               smart_str_append_printf(str, "$param%d", offset);
-       }
+       smart_str_append_printf(str, "$%s",
+               (fptr->type == ZEND_INTERNAL_FUNCTION &&
+                !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
+               ((zend_internal_arg_info*)arg_info)->name :
+               ZSTR_VAL(arg_info->name));
+
        if (fptr->type == ZEND_USER_FUNCTION && !required) {
                zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
                if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {