From bda9c83a82db703c715ae77c8b86fb8c43248d20 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sun, 6 May 2001 19:30:31 +0000 Subject: [PATCH] Recover from a parse error in include files (before, it could result in a crash under certain circumstances). Fix bug #8663 --- Zend/zend.c | 4 ++++ Zend/zend_compile.c | 17 ++++++++++++----- Zend/zend_compile.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 77ed3ef141d..61260dbe592 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -696,6 +696,10 @@ ZEND_API void zend_error(int type, const char *format, ...) } va_end(args); + + if (type==E_PARSE) { + zend_init_compiler_data_structures(CLS_C); + } } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c3a74bc12a1..67947a02fb7 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -57,14 +57,15 @@ static void build_runtime_defined_function_key(zval *result, zval *name, zend_op } -static void init_compiler_declarables(CLS_D ELS_DC) +static void init_compiler_declarables(CLS_D) { CG(declarables).ticks.type = IS_LONG; CG(declarables).ticks.value.lval = 0; } -void init_compiler(CLS_D ELS_DC) + +void zend_init_compiler_data_structures(CLS_D) { zend_stack_init(&CG(bp_stack)); zend_stack_init(&CG(function_call_stack)); @@ -75,13 +76,19 @@ void init_compiler(CLS_D ELS_DC) CG(active_class_entry) = NULL; zend_llist_init(&CG(list_llist), sizeof(list_llist_element), NULL, 0); zend_llist_init(&CG(dimension_llist), sizeof(int), NULL, 0); - zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0); CG(handle_op_arrays) = 1; CG(in_compilation) = 0; + init_compiler_declarables(CLS_C); +} + + +void init_compiler(CLS_D ELS_DC) +{ + zend_init_compiler_data_structures(CLS_C); zend_init_rsrc_list(ELS_C); - CG(unclean_shutdown) = 0; + zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0); zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0); - init_compiler_declarables(CLS_C ELS_CC); + CG(unclean_shutdown) = 0; } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 0328a4d49d6..be986f12cc0 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -208,6 +208,7 @@ BEGIN_EXTERN_C() void init_compiler(CLS_D ELS_DC); void shutdown_compiler(CLS_D); +void zend_init_compiler_data_structures(CLS_D); extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type CLS_DC);