Browse Source

handle compile time new constant. fixed #208: null as default value for parameters with array type hint produces a fatal error

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@588 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 13 years ago
parent
commit
010293a523
  1. 16
      utils.c
  2. 3
      utils.h
  3. 26
      xcache.c
  4. 3
      xcache_globals.h

16
utils.c

@ -594,6 +594,14 @@ static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */
/* }}} */
#endif
static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
{
c->name = zend_strndup(c->name, c->name_len - 1);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
}
/* }}} */
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
{
HashTable *h;
@ -631,6 +639,10 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
#ifdef HAVE_XCACHE_CONSTANT
h = OG(zend_constants);
zend_hash_init_ex(&TG(zend_constants), 20, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
{
zend_constant tmp_const;
zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const));
}
#endif
h = OG(function_table);
zend_hash_init_ex(&TG(function_table), 128, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
@ -678,7 +690,7 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
sandbox->orig_compiler_options = CG(compiler_options);
/* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK
*/
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_DELAYED_BINDING;
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION | ZEND_COMPILE_DELAYED_BINDING;
#endif
XG(sandbox) = (void *) sandbox;
@ -697,7 +709,7 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t instal
Bucket *b;
#ifdef HAVE_XCACHE_CONSTANT
b = TG(zend_constants).pListHead;
b = /*TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext :*/ TG(zend_constants).pListHead;
/* install constants */
while (b != NULL) {
zend_constant *c = (zend_constant*) b->pData;

3
utils.h

@ -94,6 +94,9 @@ typedef struct {
HashTable tmp_function_table;
HashTable tmp_class_table;
HashTable tmp_auto_globals;
#ifdef HAVE_XCACHE_CONSTANT
Bucket *tmp_internal_constant_tail;
#endif
Bucket *tmp_internal_function_tail;
Bucket *tmp_internal_class_tail;

26
xcache.c

@ -1848,20 +1848,40 @@ err:
return 0;
}
/* }}} */
static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
{
c->name = zend_strndup(c->name, c->name_len - 1);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
}
/* }}} */
static void xc_request_init(TSRMLS_D) /* {{{ */
{
int i;
if (!XG(internal_table_copied)) {
#ifdef HAVE_XCACHE_CONSTANT
zend_constant tmp_const;
#endif
zend_function tmp_func;
xc_cest_t tmp_cest;
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_destroy(&XG(internal_constant_table));
#endif
zend_hash_destroy(&XG(internal_function_table));
zend_hash_destroy(&XG(internal_class_table));
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, NULL, 1, 0);
#endif
zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
zend_hash_init_ex(&XG(internal_class_table), 10, NULL, NULL, 1, 0);
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const));
#endif
zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
@ -1920,6 +1940,9 @@ void xc_init_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
{
memset(xcache_globals, 0, sizeof(zend_xcache_globals));
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0);
#endif
zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
zend_hash_init_ex(&xcache_globals->internal_class_table, 1, NULL, NULL, 1, 0);
}
@ -1951,6 +1974,9 @@ void xc_shutdown_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
}
if (xcache_globals->internal_table_copied) {
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_destroy(&xcache_globals->internal_constant_table);
#endif
zend_hash_destroy(&xcache_globals->internal_function_table);
zend_hash_destroy(&xcache_globals->internal_class_table);
}

3
xcache_globals.h

@ -21,6 +21,9 @@ ZEND_BEGIN_MODULE_GLOBALS(xcache)
HashTable gc_op_arrays;
#endif
#ifdef HAVE_XCACHE_CONSTANT
HashTable internal_constant_table;
#endif
HashTable internal_function_table;
HashTable internal_class_table;
zend_bool internal_table_copied;

Loading…
Cancel
Save