diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2007-04-04 00:42:42 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2007-04-04 00:42:42 +0000 |
commit | 17c0c49a54db2a5dd6dc2205d0e02978b3070bae (patch) | |
tree | e1bd13682153b272b30d64af86acfe605d34af97 /Zend/zend_constants.c | |
parent | a9ca51ff1aa4b444d842d5ad771bd6f0a65e5c5c (diff) | |
download | php-git-17c0c49a54db2a5dd6dc2205d0e02978b3070bae.tar.gz |
Addres limitation of __HALT_COMPILER() that allowed only one instance
per request.
# Patch by Greg Beaver
Diffstat (limited to 'Zend/zend_constants.c')
-rw-r--r-- | Zend/zend_constants.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 1574b8d1b5..9fe79d4d97 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -274,10 +274,10 @@ ZEND_API int zend_get_constant_ex(char *name, uint name_len, zval *result, zend_ *result = **ret_constant; zval_copy_ctor(result); } - + return retval; } - + if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) { lookup_name = estrndup(name, name_len); zend_str_tolower(lookup_name, name_len); @@ -287,7 +287,26 @@ ZEND_API int zend_get_constant_ex(char *name, uint name_len, zval *result, zend_ retval=0; } } else { - retval=0; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + if (!EG(in_execution)) { + retval = 0; + } else if (name_len == sizeof("__COMPILER_HALT_OFFSET__") - 1 && memcmp(haltoff, name, name_len) == 0) { + char *cfilename, *haltname; + int len, clen; + cfilename = zend_get_executed_filename(TSRMLS_C); + clen = strlen(cfilename); + /* check for __COMPILER_HALT_OFFSET__ */ + zend_mangle_property_name(&haltname, &len, haltoff, + sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0); + if (zend_hash_find(EG(zend_constants), haltname, len+1, (void **) &c) == SUCCESS) { + retval = 1; + } else { + retval=0; + } + pefree(haltname, 0); + } else { + retval = 0; + } } efree(lookup_name); } @@ -326,7 +345,8 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) name = c->name; } - if (zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { + 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) { zend_error(E_NOTICE,"Constant %s already defined", name); free(c->name); if (!(c->flags & CONST_PERSISTENT)) { |