Created
July 6, 2023 12:07
-
-
Save dstogov/79369f7def50d6d767bd803986375071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_API.c b/Zend/zend_API.c | |
index fd1705149b..d1fe6f12b4 100644 | |
--- a/Zend/zend_API.c | |
+++ b/Zend/zend_API.c | |
@@ -2175,6 +2175,13 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio | |
} | |
while (ptr->fname) { | |
+ if (ptr->flags == ZEND_LIGHT_FUNC) { | |
+ internal_function->light_handler = (zif_light_handler)ptr->handler; | |
+ ptr++; | |
+ ZEND_ASSERT(ptr->fname != NULL); | |
+ } else { | |
+ internal_function->light_handler = NULL; | |
+ } | |
fname_len = strlen(ptr->fname); | |
internal_function->handler = ptr->handler; | |
internal_function->function_name = zend_string_init_interned(ptr->fname, fname_len, 1); | |
diff --git a/Zend/zend_API.h b/Zend/zend_API.h | |
index df9e136e4a..d2b42ab03a 100644 | |
--- a/Zend/zend_API.h | |
+++ b/Zend/zend_API.h | |
@@ -61,10 +61,14 @@ typedef struct _zend_fcall_info_cache { | |
#define ZEND_NS_NAME(ns, name) ns "\\" name | |
+#define ZEND_LIGHT_FUNC 0x7 /* static abstact final is impossible */ | |
+ | |
#define ZEND_FN(name) zif_##name | |
+#define ZEND_LIGHT_FN(name) zlf_##name | |
#define ZEND_MN(name) zim_##name | |
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) | |
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name)) | |
+#define ZEND_LIGHT_FUNCTION(name) void ZEND_FASTCALL ZEND_LIGHT_FN(name)(zval *return_value, zval *arg1) | |
#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name)) | |
#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_internal_arg_info)-1), flags }, | |
@@ -74,6 +78,7 @@ typedef struct _zend_fcall_info_cache { | |
#define ZEND_NAMED_FE(zend_name, name, arg_info) ZEND_FENTRY(zend_name, name, arg_info, 0) | |
#define ZEND_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0) | |
+#define ZEND_LIGHT_FE(name, arg_info) ZEND_FENTRY(name, (zif_handler)ZEND_LIGHT_FN(name), NULL, ZEND_LIGHT_FUNC) ZEND_FE(name, arg_info) | |
#define ZEND_DEP_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED) | |
#define ZEND_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0) | |
#define ZEND_DEP_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED) | |
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c | |
index eacd06ac4a..6f13af04ac 100644 | |
--- a/Zend/zend_closures.c | |
+++ b/Zend/zend_closures.c | |
@@ -349,7 +349,7 @@ static int zend_closure_compare_objects(zval *o1, zval *o2) /* {{{ */ | |
ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {{{ */ | |
{ | |
zend_closure *closure = (zend_closure *)object; | |
- zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function)); | |
+ zend_function *invoke = (zend_function*)ecalloc(1, sizeof(zend_function)); | |
const uint32_t keep_flags = | |
ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE; | |
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c | |
index 5e85a26957..86096a3487 100644 | |
--- a/Zend/zend_compile.c | |
+++ b/Zend/zend_compile.c | |
@@ -750,13 +750,18 @@ void zend_do_free(znode *op1) /* {{{ */ | |
if (op1->op_type == IS_TMP_VAR) { | |
zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1]; | |
- while (opline->opcode == ZEND_END_SILENCE) { | |
+ while (opline->opcode == ZEND_END_SILENCE || | |
+ opline->opcode == ZEND_EXT_FCALL_END || | |
+ opline->opcode == ZEND_OP_DATA) { | |
opline--; | |
} | |
if (opline->result_type == IS_TMP_VAR && opline->result.var == op1->u.op.var) { | |
if (opline->opcode == ZEND_BOOL || opline->opcode == ZEND_BOOL_NOT) { | |
return; | |
+ } else if (opline->opcode == ZEND_LIGHT_ICALL) { | |
+ opline->result_type = IS_UNUSED; | |
+ return; | |
} | |
} | |
@@ -3881,6 +3886,47 @@ int zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ | |
} | |
/* }}} */ | |
+int zend_compile_light_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, int type) /* {{{ */ | |
+{ | |
+ zend_op *opline; | |
+ znode arg1_node; | |
+ | |
+ if (args->children < fbc->internal_function.required_num_args) { | |
+ return FAILURE; | |
+ } | |
+ if (args->children > fbc->internal_function.num_args | |
+ && fbc->internal_function.fn_flags != ZEND_ACC_VARIADIC) { | |
+ return FAILURE; | |
+ } | |
+ | |
+ if (args->children == 0) { | |
+ arg1_node.op_type = IS_UNUSED; | |
+ } else { | |
+ zend_compile_expr(&arg1_node, args->child[0]); | |
+ } | |
+ | |
+ // TODO: compile second and following arguments | |
+ | |
+ opline = zend_emit_op(NULL, ZEND_LIGHT_ICALL, NULL, &arg1_node); | |
+ opline->extended_value = args->children; | |
+ opline->op1_type = IS_CONST; | |
+ LITERAL_STR(opline->op1, zend_string_copy(lcname)); | |
+ zend_alloc_cache_slot(opline->op1.constant); | |
+ | |
+ if (result) { | |
+ if (type == BP_VAR_R || type == BP_VAR_IS) { | |
+ zend_make_tmp_result(result, opline); | |
+ } else { | |
+ zend_make_var_result(result, opline); | |
+ } | |
+ } | |
+ | |
+ // TODO: add second and following arguments using OP_DATA instructions | |
+ | |
+ return SUCCESS; | |
+} | |
+/* }}} */ | |
+ | |
int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ | |
{ | |
if (fbc->internal_function.handler == ZEND_FN(display_disabled_function)) { | |
@@ -3932,9 +3978,13 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l | |
} else if (zend_string_equals_literal(lcname, "defined")) { | |
return zend_compile_func_defined(result, args); | |
} else if (zend_string_equals_literal(lcname, "chr") && type == BP_VAR_R) { | |
- return zend_compile_func_chr(result, args); | |
+ if (zend_compile_func_chr(result, args) == SUCCESS) { | |
+ return SUCCESS; | |
+ } | |
} else if (zend_string_equals_literal(lcname, "ord") && type == BP_VAR_R) { | |
- return zend_compile_func_ord(result, args); | |
+ if (zend_compile_func_ord(result, args) == SUCCESS) { | |
+ return SUCCESS; | |
+ } | |
} else if (zend_string_equals_literal(lcname, "call_user_func_array")) { | |
return zend_compile_func_cufa(result, args, lcname); | |
} else if (zend_string_equals_literal(lcname, "call_user_func")) { | |
@@ -3955,6 +4005,13 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l | |
return zend_compile_func_get_args(result, args); | |
} else if (zend_string_equals_literal(lcname, "array_slice")) { | |
return zend_compile_func_array_slice(result, args); | |
+ } | |
+ | |
+ if (fbc | |
+ && fbc->type == ZEND_INTERNAL_FUNCTION | |
+ && fbc->internal_function.light_handler | |
+ && args->children <= ZEND_MAX_LIGHT_HANDLER_ARGS) { | |
+ return zend_compile_light_func(result, lcname, args, fbc, type); | |
} else { | |
return FAILURE; | |
} | |
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h | |
index 62fcdc9d8d..63e430bb8c 100644 | |
--- a/Zend/zend_compile.h | |
+++ b/Zend/zend_compile.h | |
@@ -407,8 +407,11 @@ struct _zend_op_array { | |
#define ZEND_RETURN_VALUE 0 | |
#define ZEND_RETURN_REFERENCE 1 | |
+#define ZEND_MAX_LIGHT_HANDLER_ARGS 1 | |
+ | |
/* zend_internal_function_handler */ | |
typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); | |
+typedef void ZEND_FASTCALL (*zif_light_handler)(zval *return_value, zval *arg1); | |
typedef struct _zend_internal_function { | |
/* Common elements */ | |
@@ -424,6 +427,7 @@ typedef struct _zend_internal_function { | |
/* END of common elements */ | |
zif_handler handler; | |
+ zif_light_handler light_handler; | |
struct _zend_module_entry *module; | |
void *reserved[ZEND_MAX_RESERVED_RESOURCES]; | |
} zend_internal_function; | |
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c | |
index b80e7f0af6..fcd2a33a59 100644 | |
--- a/Zend/zend_execute.c | |
+++ b/Zend/zend_execute.c | |
@@ -128,6 +128,7 @@ ZEND_API const zend_internal_function zend_pass_function = { | |
0, /* required_num_args */ | |
NULL, /* arg_info */ | |
ZEND_FN(pass), /* handler */ | |
+ NULL, /* light_handler */ | |
NULL, /* module */ | |
{NULL,NULL,NULL,NULL} /* reserved */ | |
}; | |
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h | |
index bab3660a07..f08ef91d4f 100644 | |
--- a/Zend/zend_vm_def.h | |
+++ b/Zend/zend_vm_def.h | |
@@ -8320,6 +8320,39 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) | |
ZEND_VM_NEXT_OPCODE(); | |
} | |
+ZEND_VM_HANDLER(198, ZEND_LIGHT_ICALL, CONST, UNUSED|CONST|TMPVAR|CV, NUM) | |
+{ | |
+ USE_OPLINE | |
+ zval *fname = GET_OP1_ZVAL_PTR(BP_VAR_R); | |
+ zend_free_op free_op2; | |
+ zval *arg1; | |
+ zval *func; | |
+ zend_function *fbc; | |
+ zend_execute_data *call; | |
+ | |
+ SAVE_OPLINE(); | |
+ fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname)); | |
+ if (UNEXPECTED(fbc == NULL)) { | |
+ func = zend_hash_find(EG(function_table), Z_STR_P(fname)); | |
+ if (UNEXPECTED(func == NULL)) { | |
+ SAVE_OPLINE(); | |
+ zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(fname)); | |
+ HANDLE_EXCEPTION(); | |
+ } | |
+ fbc = Z_FUNC_P(func); | |
+ CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc); | |
+ } | |
+ | |
+ ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION); | |
+ ZEND_ASSERT(fbc->internal_function.light_handler != NULL); | |
+ | |
+ arg1 = GET_OP2_ZVAL_PTR(BP_VAR_R); | |
+ fbc->internal_function.light_handler( | |
+ RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : NULL, arg1); | |
+ FREE_OP2(); | |
+ ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); | |
+} | |
+ | |
ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_ADD, (res_info == MAY_BE_LONG && op1_info == MAY_BE_LONG && op2_info == MAY_BE_LONG), ZEND_ADD_LONG_NO_OVERFLOW, CONST|TMPVARCV, CONST|TMPVARCV, SPEC(NO_CONST_CONST,COMMUTATIVE)) | |
{ | |
USE_OPLINE | |
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c | |
index d28398315d..15f98b4f94 100644 | |
--- a/ext/com_dotnet/com_handlers.c | |
+++ b/ext/com_dotnet/com_handlers.c | |
@@ -272,6 +272,7 @@ static union _zend_function *com_method_get(zend_object **object_ptr, zend_strin | |
/* check cache */ | |
if (obj->method_cache == NULL || NULL == (fptr = zend_hash_find_ptr(obj->method_cache, name))) { | |
+ memset(&f, 0, sizeof(f)); \ | |
f.type = ZEND_OVERLOADED_FUNCTION; | |
f.num_args = 0; | |
f.arg_info = NULL; | |
@@ -396,6 +397,7 @@ static union _zend_function *com_constructor_get(zend_object *object) | |
static zend_internal_function c, d, v; | |
#define POPULATE_CTOR(f, fn) \ | |
+ memset(&f, 0, sizeof(f)); \ | |
f.type = ZEND_INTERNAL_FUNCTION; \ | |
f.function_name = obj->ce->name; \ | |
f.scope = obj->ce; \ | |
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c | |
index a8457c9405..3d9b08146f 100644 | |
--- a/ext/opcache/Optimizer/compact_literals.c | |
+++ b/ext/opcache/Optimizer/compact_literals.c | |
@@ -305,6 +305,12 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx | |
opline->op2.num = cache_size; | |
cache_size += sizeof(void *); | |
} | |
+ case ZEND_LIGHT_ICALL: | |
+ LITERAL_INFO(opline->op1.constant, LITERAL_FUNC, 1, 1, 1); | |
+ if (opline->op2_type == IS_CONST) { | |
+ LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1, 0, 1); | |
+ } | |
+ break; | |
default: | |
if (opline->op1_type == IS_CONST) { | |
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1, 0, 1); | |
diff --git a/ext/soap/soap.c b/ext/soap/soap.c | |
index 21deb4ec80..52ae659b19 100644 | |
--- a/ext/soap/soap.c | |
+++ b/ext/soap/soap.c | |
@@ -652,6 +652,7 @@ PHP_MINIT_FUNCTION(soap) | |
{ | |
zend_internal_function fe; | |
+ memset(&fe, 0, sizeof(fe)); | |
fe.type = ZEND_INTERNAL_FUNCTION; | |
fe.handler = ZEND_MN(SoapClient___call); | |
fe.function_name = NULL; | |
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c | |
index 93d469168b..00431dcd5d 100644 | |
--- a/ext/standard/basic_functions.c | |
+++ b/ext/standard/basic_functions.c | |
@@ -2808,7 +2808,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ | |
PHP_FE(str_repeat, arginfo_str_repeat) | |
PHP_FE(count_chars, arginfo_count_chars) | |
PHP_FE(chunk_split, arginfo_chunk_split) | |
- PHP_FE(trim, arginfo_trim) | |
+ PHP_LIGHT_FE(trim, arginfo_trim) | |
PHP_FE(ltrim, arginfo_ltrim) | |
PHP_FE(strip_tags, arginfo_strip_tags) | |
PHP_FE(similar_text, arginfo_similar_text) | |
@@ -2824,8 +2824,8 @@ const zend_function_entry basic_functions[] = { /* {{{ */ | |
PHP_FE(soundex, arginfo_soundex) | |
PHP_FE(levenshtein, arginfo_levenshtein) | |
- PHP_FE(chr, arginfo_chr) | |
- PHP_FE(ord, arginfo_ord) | |
+ PHP_LIGHT_FE(chr, arginfo_chr) | |
+ PHP_LIGHT_FE(ord, arginfo_ord) | |
PHP_FE(parse_str, arginfo_parse_str) | |
PHP_FE(str_getcsv, arginfo_str_getcsv) | |
PHP_FE(str_pad, arginfo_str_pad) | |
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h | |
index d5d3e09f81..02f8cfaf29 100644 | |
--- a/ext/standard/php_string.h | |
+++ b/ext/standard/php_string.h | |
@@ -30,6 +30,7 @@ PHP_FUNCTION(str_replace); | |
PHP_FUNCTION(str_ireplace); | |
PHP_FUNCTION(rtrim); | |
PHP_FUNCTION(trim); | |
+PHP_LIGHT_FUNCTION(trim); | |
PHP_FUNCTION(ltrim); | |
PHP_FUNCTION(soundex); | |
PHP_FUNCTION(levenshtein); | |
@@ -68,7 +69,9 @@ PHP_FUNCTION(addslashes); | |
PHP_FUNCTION(stripcslashes); | |
PHP_FUNCTION(stripslashes); | |
PHP_FUNCTION(chr); | |
+PHP_LIGHT_FUNCTION(chr); | |
PHP_FUNCTION(ord); | |
+PHP_LIGHT_FUNCTION(ord); | |
PHP_FUNCTION(nl2br); | |
PHP_FUNCTION(setlocale); | |
PHP_FUNCTION(localeconv); | |
diff --git a/ext/standard/string.c b/ext/standard/string.c | |
index 55bcca14db..844b99f522 100644 | |
--- a/ext/standard/string.c | |
+++ b/ext/standard/string.c | |
@@ -921,6 +921,48 @@ PHP_FUNCTION(trim) | |
} | |
/* }}} */ | |
+/* {{{ proto string trim(string str [, string character_mask]) | |
+ Strips whitespace from the beginning and end of a string */ | |
+PHP_LIGHT_FUNCTION(trim) | |
+{ | |
+ zend_string *str; | |
+ | |
+ do { | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_STRING)) { | |
+ str = zend_string_copy(Z_STR_P(arg1)); | |
+ break; | |
+ } else if (Z_ISREF_P(arg1)) { | |
+ ZVAL_DEREF(arg1); | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_STRING)) { | |
+ str = zend_string_copy(Z_STR_P(arg1)); | |
+ break; | |
+ } | |
+ } | |
+ if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) { | |
+ zend_internal_type_error(1, "trim() expects parameter 1 to be string, %s given", | |
+ zend_zval_type_name(arg1)); | |
+ RETURN_NULL(); | |
+ } else { | |
+ zval tmp; | |
+ | |
+ ZVAL_DUP(&tmp, arg1); // TODO: avoid duplication ??? | |
+ if (!zend_parse_arg_str_weak(&tmp, &str)) { | |
+ zval_ptr_dtor(&tmp); | |
+ zend_internal_type_error(0, "trim() expects parameter 1 to be string, %s given", | |
+ zend_zval_type_name(arg1)); | |
+ RETURN_NULL(); | |
+ } | |
+ } | |
+ } while (0); | |
+ | |
+ if (return_value) { | |
+ RETVAL_STR(php_trim_int(str, NULL, 0, 3)); | |
+ } | |
+ | |
+ zend_string_release(str); | |
+} | |
+/* }}} */ | |
+ | |
/* {{{ proto string rtrim(string str [, string character_mask]) | |
Removes trailing whitespace */ | |
PHP_FUNCTION(rtrim) | |
@@ -2767,6 +2809,49 @@ PHP_FUNCTION(ord) | |
} | |
/* }}} */ | |
+/* {{{ proto int ord(string character) | |
+ Returns ASCII value of character | |
+ Warning: This function is special-cased by zend_compile.c and so is bypassed for constant string argument */ | |
+PHP_LIGHT_FUNCTION(ord) | |
+{ | |
+ zend_string *str; | |
+ | |
+ do { | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_STRING)) { | |
+ str = zend_string_copy(Z_STR_P(arg1)); | |
+ break; | |
+ } else if (Z_ISREF_P(arg1)) { | |
+ ZVAL_DEREF(arg1); | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_STRING)) { | |
+ str = zend_string_copy(Z_STR_P(arg1)); | |
+ break; | |
+ } | |
+ } | |
+ if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) { | |
+ zend_internal_type_error(1, "ord() expects parameter 1 to be string, %s given", | |
+ zend_zval_type_name(arg1)); | |
+ RETURN_NULL(); | |
+ } else { | |
+ zval tmp; | |
+ | |
+ ZVAL_DUP(&tmp, arg1); // TODO: avoid duplication ??? | |
+ if (!zend_parse_arg_str_weak(&tmp, &str)) { | |
+ zval_ptr_dtor(&tmp); | |
+ zend_internal_type_error(0, "ord() expects parameter 1 to be string, %s given", | |
+ zend_zval_type_name(arg1)); | |
+ RETURN_NULL(); | |
+ } | |
+ } | |
+ } while (0); | |
+ | |
+ if (return_value) { | |
+ RETVAL_LONG((unsigned char) ZSTR_VAL(str)[0]); | |
+ } | |
+ | |
+ zend_string_release(str); | |
+} | |
+/* }}} */ | |
+ | |
/* {{{ proto string chr(int ascii) | |
Converts ASCII code to a character | |
Warning: This function is special-cased by zend_compile.c and so is bypassed for constant integer argument */ | |
@@ -2787,6 +2872,44 @@ PHP_FUNCTION(chr) | |
} | |
/* }}} */ | |
+/* {{{ proto string chr(int ascii) | |
+ Converts ASCII code to a character | |
+ Warning: This function is special-cased by zend_compile.c and so is bypassed for constant integer argument */ | |
+PHP_LIGHT_FUNCTION(chr) | |
+{ | |
+ zend_long c; | |
+ | |
+ do { | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_LONG)) { | |
+ c = Z_LVAL_P(arg1); | |
+ break; | |
+ } else if (Z_ISREF_P(arg1)) { | |
+ ZVAL_DEREF(arg1); | |
+ if (EXPECTED(Z_TYPE_P(arg1) == IS_LONG)) { | |
+ c = Z_LVAL_P(arg1); | |
+ break; | |
+ } | |
+ } | |
+ if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) { | |
+ c = 0; | |
+ } else { | |
+ zval tmp; | |
+ | |
+ ZVAL_DUP(&tmp, arg1); // TODO: avoid duplication ??? | |
+ if (!zend_parse_arg_long_weak(&tmp, &c)) { | |
+ zval_ptr_dtor(&tmp); | |
+ c = 0; | |
+ } | |
+ } | |
+ } while (0); | |
+ | |
+ if (return_value) { | |
+ c &= 0xff; | |
+ ZVAL_INTERNED_STR(return_value, ZSTR_CHAR(c)); | |
+ } | |
+} | |
+/* }}} */ | |
+ | |
/* {{{ php_ucfirst | |
Uppercase the first character of the word in a native string */ | |
static zend_string* php_ucfirst(zend_string *str) | |
diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c | |
index 773225a64d..b1640c2d69 100644 | |
--- a/ext/zend_test/test.c | |
+++ b/ext/zend_test/test.c | |
@@ -134,7 +134,7 @@ static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ | |
/* }}} */ | |
static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ { | |
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); | |
+ zend_internal_function *fptr = ecalloc(1, sizeof(zend_internal_function)); | |
fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY; | |
fptr->num_args = 1; | |
fptr->arg_info = NULL; | |
@@ -149,7 +149,7 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri | |
/* }}} */ | |
static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ { | |
- zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); | |
+ zend_internal_function *fptr = ecalloc(1, sizeof(zend_internal_function)); | |
fptr->type = ZEND_OVERLOADED_FUNCTION; | |
fptr->num_args = 1; | |
fptr->arg_info = NULL; | |
diff --git a/main/php.h b/main/php.h | |
index 6dc05caea7..1cc463c7c5 100644 | |
--- a/main/php.h | |
+++ b/main/php.h | |
@@ -409,11 +409,13 @@ END_EXTERN_C() | |
#define PHP_MN ZEND_MN | |
#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION | |
#define PHP_FUNCTION ZEND_FUNCTION | |
+#define PHP_LIGHT_FUNCTION ZEND_LIGHT_FUNCTION | |
#define PHP_METHOD ZEND_METHOD | |
#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE | |
#define PHP_NAMED_FE ZEND_NAMED_FE | |
#define PHP_FE ZEND_FE | |
+#define PHP_LIGHT_FE ZEND_LIGHT_FE | |
#define PHP_DEP_FE ZEND_DEP_FE | |
#define PHP_FALIAS ZEND_FALIAS | |
#define PHP_DEP_FALIAS ZEND_DEP_FALIAS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment