summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2012-10-08 23:00:57 +0800
committerXinchen Hui <laruence@php.net>2012-10-08 23:00:57 +0800
commit6cd6a74c5a5b0eb503399848c814dd2f717b076b (patch)
treec2af672db314195985120a41c60af0a173747d45
parent531e2533dd2baf5cf10e8de7074ca0b94386dba4 (diff)
parent67611c67fa5a3b2c199d41ef7df3307308c56faa (diff)
downloadphp-git-6cd6a74c5a5b0eb503399848c814dd2f717b076b.tar.gz
Merge branch 'PHP-5.4'
-rw-r--r--Zend/tests/bug63219.phpt18
-rw-r--r--Zend/zend_compile.c14
2 files changed, 28 insertions, 4 deletions
diff --git a/Zend/tests/bug63219.phpt b/Zend/tests/bug63219.phpt
new file mode 100644
index 0000000000..999be4a853
--- /dev/null
+++ b/Zend/tests/bug63219.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #63219 (Segfault when aliasing trait method when autoloader throws excpetion)
+--FILE--
+<?php
+trait TFoo {
+ public function fooMethod(){}
+}
+
+class C {
+ use TFoo {
+ Typo::fooMethod as tf;
+ }
+}
+
+echo "okey";
+?>
+--EXPECTF--
+Fatal error: Could not find trait Typo in %sbug63219.php on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 8046089ed4..0c03e4cf18 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4056,8 +4056,10 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
/** Resolve classes for all precedence operations. */
if (cur_precedence->exclude_from_classes) {
cur_method_ref = cur_precedence->trait_method;
- cur_precedence->trait_method->ce = zend_fetch_class(cur_method_ref->class_name,
- cur_method_ref->cname_len, ZEND_FETCH_CLASS_TRAIT TSRMLS_CC);
+ if (!(cur_precedence->trait_method->ce = zend_fetch_class(cur_method_ref->class_name, cur_method_ref->cname_len,
+ ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) {
+ zend_error(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name);
+ }
/** Ensure that the prefered method is actually available. */
lcname = zend_str_tolower_dup(cur_method_ref->method_name,
@@ -4084,7 +4086,9 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
char* class_name = (char*)cur_precedence->exclude_from_classes[j];
zend_uint name_length = strlen(class_name);
- cur_precedence->exclude_from_classes[j] = zend_fetch_class(class_name, name_length, ZEND_FETCH_CLASS_TRAIT TSRMLS_CC);
+ if (!(cur_precedence->exclude_from_classes[j] = zend_fetch_class(class_name, name_length, ZEND_FETCH_CLASS_TRAIT |ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) {
+ zend_error(E_COMPILE_ERROR, "Could not find trait %s", class_name);
+ }
/* make sure that the trait method is not from a class mentioned in
exclude_from_classes, for consistency */
@@ -4111,7 +4115,9 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
/** For all aliases with an explicit class name, resolve the class now. */
if (ce->trait_aliases[i]->trait_method->class_name) {
cur_method_ref = ce->trait_aliases[i]->trait_method;
- cur_method_ref->ce = zend_fetch_class(cur_method_ref->class_name, cur_method_ref->cname_len, ZEND_FETCH_CLASS_TRAIT TSRMLS_CC);
+ if (!(cur_method_ref->ce = zend_fetch_class(cur_method_ref->class_name, cur_method_ref->cname_len, ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) {
+ zend_error(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name);
+ }
/** And, ensure that the referenced method is resolvable, too. */
lcname = zend_str_tolower_dup(cur_method_ref->method_name,