diff options
Diffstat (limited to 'Zend/zend_constants.c')
-rw-r--r-- | Zend/zend_constants.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 04452e40dd..b566146af0 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -473,8 +473,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); str_free(c->name); if (!(c->flags & CONST_PERSISTENT)) { |