From 8901635d73811d469118c70708fa2f1908ac12c1 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 13 Nov 2010 18:46:11 +0000 Subject: [PATCH] - Fixed bug #53305 (E_NOTICE when defining a constant starts with __COMPILER_HALT_OFFSET__) - Fixed a part of bug #53260 (the __COMPILER_HALT_OFFSET__ name is not shown in the E_NOTICE) --- NEWS | 2 ++ Zend/tests/bug53305.phpt | 19 +++++++++++++++++++ Zend/zend_constants.c | 11 +++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Zend/tests/bug53305.phpt diff --git a/NEWS b/NEWS index 200a7bcb9c..6d1b92b586 100644 --- a/NEWS +++ b/NEWS @@ -62,6 +62,8 @@ - Fixed the filter extension accepting IPv4 octets with a leading 0 as that belongs to the unsupported "dotted octal" representation. (Gustavo) +- Fixed bug #53305 (E_NOTICE when defining a constant starts with + __COMPILER_HALT_OFFSET__). (Felipe) - Fixed bug #53297 (gettimeofday implementation in php/win32/time.c can return 1 million microsecs). (ped at 7gods dot org) - Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape diff --git a/Zend/tests/bug53305.phpt b/Zend/tests/bug53305.phpt new file mode 100644 index 0000000000..c922ac6338 --- /dev/null +++ b/Zend/tests/bug53305.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #53305 (E_NOTICE when defining a constant starts with __COMPILER_HALT_OFFSET__) +--FILE-- + +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d +int(1) +int(4) diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 0543903e84..bae13eaf02 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -434,8 +434,15 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) } } - if ((strncmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) || - zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { + /* Check if the user is trying to define the internal pseudo constant name __COMPILER_HALT_OFFSET__ */ + if ((c->name_len == sizeof("__COMPILER_HALT_OFFSET__") + && !memcmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) + || zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { + + /* The internal __COMPILER_HALT_OFFSET__ is prefixed by NULL byte */ + if (strncmp(name+1, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")) == 0) { + name++; + } zend_error(E_NOTICE,"Constant %s already defined", name); free(c->name); if (!(c->flags & CONST_PERSISTENT)) { -- 2.40.0