From f149245b8dde0419dc6b49ec81d303af6264c1a1 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 18 Apr 2006 18:44:47 +0000 Subject: [PATCH] - fix SEGV if an error occurs inside a callback and error handling is set to EH_THROW --- http_request_api.c | 4 +++- http_request_object.c | 4 +++- php_http_std_defs.h | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/http_request_api.c b/http_request_api.c index 06b69f7..4180165 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -1004,7 +1004,9 @@ static int http_curl_progress_callback(void *ctx, double dltotal, double dlnow, add_assoc_double(param, "ultotal", ultotal); add_assoc_double(param, "ulnow", ulnow); - call_user_function(EG(function_table), NULL, request->_progress_callback, &retval, 1, ¶m TSRMLS_CC); + with_error_handling(EH_NORMAL, NULL) { + call_user_function(EG(function_table), NULL, request->_progress_callback, &retval, 1, ¶m TSRMLS_CC); + } end_error_handling(); zval_ptr_dtor(¶m); zval_dtor(&retval); diff --git a/http_request_object.c b/http_request_object.c index 11a6230..4377dcc 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -693,7 +693,9 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this MAKE_STD_ZVAL(param); ZVAL_BOOL(param, ret == SUCCESS); - zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "onfinish", NULL, param); + with_error_handling(EH_NORMAL, NULL) { + zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "onfinish", NULL, param); + } end_error_handling(); zval_ptr_dtor(¶m); } diff --git a/php_http_std_defs.h b/php_http_std_defs.h index a3a3056..9f22bcf 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -292,6 +292,20 @@ typedef int STATUS; #endif /* ZEND_ENGINE_2 */ /* }}} */ +#ifdef ZEND_ENGINE_2 +# define with_error_handling(eh, ec) \ + { \ + error_handling_t __eh = PG(error_handling); \ + zend_class_entry *__ec= PG(exception_class); \ + php_set_error_handling(eh, ec TSRMLS_CC); +# define end_error_handling() \ + php_set_error_handling(__eh, __ec TSRMLS_CC); \ + } +#else +# define with_error_handling(eh, ec) +# define end_error_handling() +#endif + #ifndef E_THROW # define E_THROW 0 #endif -- 2.30.2