]> granicus.if.org Git - php/commitdiff
- Fixed bug #60099 (__halt_compiler() works in braced namespaces)
authorFelipe Pena <felipe@php.net>
Wed, 16 Nov 2011 17:41:40 +0000 (17:41 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 16 Nov 2011 17:41:40 +0000 (17:41 +0000)
NEWS
Zend/tests/bug60099.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index d3ab317ae16ef356bcd154d079be4543c7a43d83..74d1ce1c728a0dbfa4b3017407c059cff550c4e9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #60227 (header() cannot detect the multi-line header with 
      CR(0x0D)). (rui)
+  . Fixed bug #60099 (__halt_compiler() works in braced namespaces). (Felipe)
   . Fixed bug #55874 (GCC does not provide __sync_fetch_and_add on some archs).
     (klightspeed at netspace dot net dot au)
   . Fixed bug #52624 (tempnam() by-pass open_basedir with nonexistent
diff --git a/Zend/tests/bug60099.phpt b/Zend/tests/bug60099.phpt
new file mode 100644 (file)
index 0000000..13e2f54
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #60099 (__halt_compiler() works in braced namespaces)
+--FILE--
+<?php
+namespace foo {
+       __halt_compiler();
+
+?>
+--EXPECTF--
+Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %s on line %d
index 421a849255219ddf2e5a1437cfd6a4781f493168..47931e6dac669c1fab6af8a010d9741bbfc54f7e 100644 (file)
@@ -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);