From caa863dc42fcae9aa7efb29ed980dc4da87d1f14 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 16 Nov 2011 17:41:40 +0000 Subject: [PATCH] - Fixed bug #60099 (__halt_compiler() works in braced namespaces) --- Zend/tests/bug60099.phpt | 10 ++++++++++ Zend/zend_compile.c | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 Zend/tests/bug60099.phpt diff --git a/Zend/tests/bug60099.phpt b/Zend/tests/bug60099.phpt new file mode 100644 index 0000000000..13e2f54b09 --- /dev/null +++ b/Zend/tests/bug60099.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #60099 (__halt_compiler() works in braced namespaces) +--FILE-- + +--EXPECTF-- +Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 204f28e239..dde71ed549 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5311,6 +5311,11 @@ void zend_do_halt_compiler_register(TSRMLS_D) /* {{{ */ char *name, *cfilename; char haltoff[] = "__COMPILER_HALT_OFFSET__"; int len, clen; + + if (CG(has_bracketed_namespaces) && CG(in_namespace)) { + zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); + } + cfilename = zend_get_compiled_filename(TSRMLS_C); clen = strlen(cfilename); zend_mangle_property_name(&name, &len, haltoff, sizeof(haltoff) - 1, cfilename, clen, 0); -- 2.50.1