From ffded0020b7f3b218074e785a2c435eebdcde176 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 4 Mar 2012 19:34:19 +0000 Subject: [PATCH] Fixed Bug #61052 (Missing error check in trait 'insteadof' clause) --- NEWS | 1 + Zend/tests/traits/bug61052.phpt | 18 ++++++++++++++++++ Zend/zend_compile.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/traits/bug61052.phpt diff --git a/NEWS b/NEWS index 1be7ccf16c..638c4e7826 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ PHP NEWS vars). (Laruence) . Fixed bug #61011 (Crash when an exception is thrown by __autoload accessing a static property). (Laruence) + . Fixed bug #61052 (Missing error check in trait 'insteadof' clause). (Stefan) . Fixed bug #61072 (Memory leak when restoring an exception handler). (Nikic, Laruence) . Fixed bug #61087 (Memory leak in parse_ini_file when specifying diff --git a/Zend/tests/traits/bug61052.phpt b/Zend/tests/traits/bug61052.phpt new file mode 100644 index 0000000000..421e9074e5 --- /dev/null +++ b/Zend/tests/traits/bug61052.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #61052 (missing error check in trait 'insteadof' clause) +--FILE-- +exclude_from_classes[j]) { 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); + + /* make sure that the trait method is not from a class mentioned in + exclude_from_classes, for consistency */ + if (cur_precedence->trait_method->ce == cur_precedence->exclude_from_classes[i]) { + zend_error(E_COMPILE_ERROR, + "Inconsistent insteadof definition. " + "The method %s is to be used from %s, but %s is also on the exclude list", + cur_method_ref->method_name, + cur_precedence->trait_method->ce->name, + cur_precedence->trait_method->ce->name); + } + efree(class_name); j++; } -- 2.50.1