com php-src: Merge branch 'PHP-7.0': Zend/zend_constants.c
| From: | Nikita Popov | Date: | Mon, 02 May 2016 18:04:24 +0000 |
| Subject: | com php-src: Merge branch 'PHP-7.0': Zend/zend_constants.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92001@lists.php.net to get a copy of this message | ||
Commit: 0ce7189265b294f50978963239721c3ccb6f4a83
Author: Nikita Popov <nikic@php.net> Mon, 2 May 2016 20:02:44 +0200
Parents: 5e10735d07578fcf656e40d0a967a9bc557ad838 ec7c3c22b69814aa0b64c6b9aa9fef17f99103ab
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0ce7189265b294f50978963239721c3ccb6f4a83
Log:
Merge branch 'PHP-7.0'
Conflicts:
Zend/zend_constants.c
Changed paths:
MM Zend/zend_constants.c
Diff:
diff --cc Zend/zend_constants.c
index 22162d8,41edcd9..3e09f0c
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@@ -327,29 -314,30 +326,22 @@@ ZEND_API zval *zend_get_constant_ex(zen
int class_name_len = colon - name - 1;
size_t const_name_len = name_len - class_name_len - 2;
zend_string *constant_name = zend_string_init(colon + 1, const_name_len, 0);
- char *lcname;
+ zend_string *class_name = zend_string_init(name, class_name_len, 0);
zval *ret_constant = NULL;
- ALLOCA_FLAG(use_heap)
- class_name = zend_string_init(name, class_name_len, 0);
- lcname = do_alloca(class_name_len + 1, use_heap);
- zend_str_tolower_copy(lcname, name, class_name_len);
- if (!scope) {
- if (EG(current_execute_data)) {
- scope = EG(scope);
- } else {
- scope = CG(active_class_entry);
- }
- }
--
- if (class_name_len == sizeof("self")-1 &&
- !memcmp(lcname, "self", sizeof("self")-1)) {
+ if (zend_string_equals_literal_ci(class_name, "self")) {
if (UNEXPECTED(!scope)) {
zend_throw_error(NULL, "Cannot access self:: when no class scope is active");
- return NULL;
+ goto failure;
}
ce = scope;
- } else if (class_name_len == sizeof("parent")-1 &&
- !memcmp(lcname, "parent", sizeof("parent")-1)) {
+ } else if (zend_string_equals_literal_ci(class_name, "parent")) {
if (UNEXPECTED(!scope)) {
zend_throw_error(NULL, "Cannot access parent:: when no class scope is active");
- return NULL;
+ goto failure;
} else if (UNEXPECTED(!scope->parent)) {
zend_throw_error(NULL, "Cannot access parent:: when current class scope has no
parent");
- return NULL;
+ goto failure;
} else {
ce = scope->parent;
}
@@@ -363,47 -350,25 +354,40 @@@
} else {
ce = zend_fetch_class(class_name, flags);
}
- free_alloca(lcname, use_heap);
if (ce) {
- ret_constant = zend_hash_find(&ce->constants_table, constant_name);
- if (ret_constant == NULL) {
+ zend_class_constant *c = zend_hash_find_ptr(&ce->constants_table, constant_name);
+ if (c == NULL) {
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
zend_throw_error(NULL, "Undefined class constant '%s::%s'",
ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
- zend_string_release(class_name);
- zend_string_free(constant_name);
- return NULL;
++ goto failure;
+ }
+ ret_constant = NULL;
+ } else {
+ if (!zend_verify_const_access(c, scope)) {
+ zend_throw_error(NULL, "Cannot access %s const %s::%s",
zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
- zend_string_release(class_name);
- zend_string_free(constant_name);
- return NULL;
++ goto failure;
}
- } else if (Z_ISREF_P(ret_constant)) {
- ret_constant = Z_REFVAL_P(ret_constant);
+ ret_constant = &c->value;
}
}
+
-failure:
- zend_string_release(class_name);
- zend_string_free(constant_name);
if (ret_constant && Z_CONSTANT_P(ret_constant)) {
- if (UNEXPECTED(zval_update_constant_ex(ret_constant, 1, ce) != SUCCESS)) {
- return NULL;
+ if (Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) {
+ if (IS_CONSTANT_VISITED(ret_constant)) {
+ zend_throw_error(NULL, "Cannot declare self-referencing constant
'%s::%s'", ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
- zend_string_release(class_name);
- zend_string_free(constant_name);
- return NULL;
++ goto failure;
+ }
+ MARK_CONSTANT_VISITED(ret_constant);
}
+ if (UNEXPECTED(zval_update_constant_ex(ret_constant, ce) != SUCCESS)) {
+ RESET_CONSTANT_VISITED(ret_constant);
- zend_string_release(class_name);
- zend_string_free(constant_name);
- return NULL;
++ goto failure;
+ }
+ RESET_CONSTANT_VISITED(ret_constant);
}
++failure:
+ zend_string_release(class_name);
+ zend_string_free(constant_name);
return ret_constant;
}