diff --git a/Zend/zend-scanner.l b/Zend/zend-scanner.l index a69a5109825..cbbb19a1869 100644 --- a/Zend/zend-scanner.l +++ b/Zend/zend-scanner.l @@ -460,6 +460,8 @@ static inline int prepare_string_for_scanning(zval *str CLS_DC) CG(ZFL)->switch_streams(input_stream, &cout); #endif + zend_set_compiled_filename("Eval code"); + CG(zend_lineno) = 1; return SUCCESS; } diff --git a/Zend/zend.c b/Zend/zend.c index 48bad64c21f..692d766576b 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -527,9 +527,9 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents) ZEND_API void zend_error(int type, const char *format, ...) { va_list args; - zval **params; - zval retval; - zval error_type, error_message; + zval ***params; + zval *retval; + zval *error_type, *error_message; char *error_filename; uint error_lineno; ELS_FETCH(); @@ -589,33 +589,34 @@ ZEND_API void zend_error(int type, const char *format, ...) break; default: /* Handle the error in user space */ - INIT_PZVAL(&error_message); - INIT_PZVAL(&error_type); - error_message.value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE); + ALLOC_INIT_ZVAL(error_message); + ALLOC_INIT_ZVAL(error_type); + error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE); #ifdef HAVE_VSNPRINTF - error_message.value.str.len = vsnprintf(error_message.value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args); + error_message->value.str.len = vsnprintf(error_message->value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args); #else /* This is risky... */ - error_message.value.str.len = vsprintf(error_message.value.str.val, format, args); + error_message->value.str.len = vsprintf(error_message->value.str.val, format, args); #endif - error_message.type = IS_STRING; + error_message->type = IS_STRING; - error_type.value.lval = type; - error_type.type = IS_LONG; + error_type->value.lval = type; + error_type->type = IS_LONG; - params = (zval **) emalloc(sizeof(zval *)*2); + params = (zval ***) emalloc(sizeof(zval **)*2); params[0] = &error_type; params[1] = &error_message; - if (call_user_function(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params)==SUCCESS) { - zval_dtor(&retval); + if (call_user_function_ex(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params, 1, NULL)==SUCCESS) { + zval_ptr_dtor(&retval); } else { /* The user error handler failed, use built-in error handler */ zend_error_cb(type, error_filename, error_lineno, format, args); } efree(params); - efree(error_message.value.str.val); + zval_ptr_dtor(&error_message); + zval_ptr_dtor(&error_type); break; } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 5412a4fe882..31b81f2572e 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -178,7 +178,7 @@ ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, i ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate); ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, int param_count, zval *params[]); -ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation); +ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table); ZEND_API int add_property_long(zval *arg, char *key, long l); ZEND_API int add_property_unset(zval *arg, char *key); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 8ba3ff8213f..1ff6bd937e5 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -325,7 +325,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n for (i=0; itype == ZEND_USER_FUNCTION) { calling_symbol_table = EG(active_symbol_table); - ALLOC_HASHTABLE(EG(active_symbol_table)); - zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); + if (symbol_table) { + EG(active_symbol_table) = symbol_table; + } else { + ALLOC_HASHTABLE(EG(active_symbol_table)); + zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); + } if (object) { zval *dummy, **this_ptr; @@ -434,8 +438,10 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio EG(active_op_array) = (zend_op_array *) function_state.function; original_opline_ptr = EG(opline_ptr); zend_execute(EG(active_op_array) ELS_CC); - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); + if (!symbol_table) { + zend_hash_destroy(EG(active_symbol_table)); + FREE_HASHTABLE(EG(active_symbol_table)); + } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; EG(return_value_ptr_ptr)=original_return_value;