From 741ca1671164f51d330f3518ea14591ba8feff8d Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Wed, 28 Jul 1999 17:59:55 +0000 Subject: [PATCH] - Fixed various inheritance problems & Andrey's leak --- Zend/zend_compile.c | 2 ++ Zend/zend_execute.c | 2 ++ Zend/zend_execute_API.c | 9 ++++++++- Zend/zend_globals.h | 3 ++- Zend/zend_hash.c | 3 --- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ee02ca0019c..d7fcc0002d0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1299,6 +1299,8 @@ void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_ /* copy default properties */ zend_hash_copy(&CG(class_entry).default_properties, &parent_class->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *)); + CG(class_entry).parent = parent_class; + zval_dtor(&parent_class_name->u.constant); } else { runtime_inheritence = 1; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 2b5be29159c..e0bc6c8936b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1450,6 +1450,7 @@ do_fcall_common: EG(opline_ptr) = &opline; EG(active_op_array) = op_array; EG(return_value)=original_return_value; + EG(destroying_function_symbol_table) = 1; if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { zend_hash_destroy(function_state.function_symbol_table); efree(function_state.function_symbol_table); @@ -1457,6 +1458,7 @@ do_fcall_common: *(++EG(symtable_cache_ptr)) = function_state.function_symbol_table; zend_hash_clean(*EG(symtable_cache_ptr)); } + EG(destroying_function_symbol_table) = 0; EG(active_symbol_table) = calling_symbol_table; } else { /* ZEND_OVERLOADED_FUNCTION */ call_overloaded_function(opline->extended_value, &Ts[opline->result.u.var].tmp_var, &EG(regular_list), &EG(persistent_list) ELS_CC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a5b94889c94..586249a3454 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -91,6 +91,7 @@ void init_executor(CLS_D ELS_DC) EG(error_zval).EA.is_ref=0; EG(error_zval).EA.locks = 0; EG(error_zval_ptr)=&EG(error_zval); + EG(destroying_function_symbol_table) = 0; zend_ptr_stack_init(&EG(arg_types_stack)); zend_stack_init(&EG(overloaded_objects_stack)); /* destroys stack frame, therefore makes core dumps worthless */ @@ -215,7 +216,13 @@ ZEND_API int zval_ptr_dtor(zval **zval_ptr) safe_free_zval_ptr(*zval_ptr); } if (locked) { - return 0; /* don't kill the container bucket */ + ELS_FETCH(); + + if (EG(destroying_function_symbol_table)) { + return 1; + } else { + return 0; /* don't kill the container bucket */ + } } else { return 1; } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index d922ac7f727..aae7624c7a2 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -199,9 +199,10 @@ struct _zend_executor_globals { HashTable *zend_constants; /* constants table */ long precision; + zend_bool destroying_function_symbol_table; /* for extended information support */ - unsigned char no_extensions; + zend_bool no_extensions; HashTable regular_list; HashTable persistent_list; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index f9322cc3f88..c489591f60f 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -744,9 +744,6 @@ ZEND_API void zend_hash_destroy(HashTable *ht) } if (delete_bucket) { pefree(q,ht->persistent); - } else { - int i; - i=2; } } pefree(ht->arBuckets,ht->persistent);