com php-src: Compile error on function definition conflicting with import: Zend/zend_compile.c
| From: | Ferenc Kovacs | Date: | Fri, 23 Aug 2013 21:39:42 +0000 |
| Subject: | com php-src: Compile error on function definition conflicting with import: Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74285@lists.php.net to get a copy of this message | ||
Commit: 30f16c354060f730dbc321799613527e5a7ea00e
Author: Igor Wiedler <igor@wiedler.ch> Fri, 23 Aug 2013 23:39:42 +0200
Parents: 5b18530e8cc8635592cfb98da0ecbc045c83bfe6
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=30f16c354060f730dbc321799613527e5a7ea00e
Log:
Compile error on function definition conflicting with import
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 8725083..95723c9 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -428,7 +428,7 @@ int zend_add_ns_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS
ns_separator = (const char*)zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv));
- if (ns_separator != NULL) {
+ if (ns_separator != NULL) {
ns_separator += 1;
lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv));
lc_name = zend_str_tolower_dup(ns_separator, lc_len);
@@ -1701,6 +1701,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode
*function_n
} else {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
zval key;
+ zval **ns_name;
if (CG(current_namespace)) {
/* Prefix function name with current namespace name */
@@ -1716,6 +1717,19 @@ void zend_do_begin_function_declaration(znode *function_token, znode
*function_n
lcname = zend_str_tolower_dup(name, name_len);
}
+ /* Function name must not conflict with import names */
+ if (CG(current_import_function) &&
+ zend_hash_find(CG(current_import_function), lcname, Z_STRLEN(function_name->u.constant)+1,
(void**)&ns_name) == SUCCESS) {
+
+ char *tmp = zend_str_tolower_dup(Z_STRVAL_PP(ns_name), Z_STRLEN_PP(ns_name));
+
+ if (Z_STRLEN_PP(ns_name) != Z_STRLEN(function_name->u.constant) ||
+ memcmp(tmp, lcname, Z_STRLEN(function_name->u.constant))) {
+ zend_error(E_COMPILE_ERROR, "Cannot declare function %s because the name is already in
use", Z_STRVAL(function_name->u.constant));
+ }
+ efree(tmp);
+ }
+
opline->opcode = ZEND_DECLARE_FUNCTION;
opline->op1_type = IS_CONST;
build_runtime_defined_function_key(&key, lcname, name_len TSRMLS_CC);