- fix SEGV if an error occurs inside a callback and error handling is set to EH_THROW
authorMichael Wallner <mike@php.net>
Tue, 18 Apr 2006 18:44:47 +0000 (18:44 +0000)
committerMichael Wallner <mike@php.net>
Tue, 18 Apr 2006 18:44:47 +0000 (18:44 +0000)
http_request_api.c
http_request_object.c
php_http_std_defs.h

index 06b69f719e8039b72788da31a6f3043417258dca..41801656e82849fad99c28d5c2bca5a24ee05be0 100644 (file)
@@ -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, &param TSRMLS_CC);
+       with_error_handling(EH_NORMAL, NULL) {
+               call_user_function(EG(function_table), NULL, request->_progress_callback, &retval, 1, &param TSRMLS_CC);
+       } end_error_handling();
        
        zval_ptr_dtor(&param);
        zval_dtor(&retval);
index 11a623030077bb658649f77f262f203bc07702a1..4377dcc1e37f0888064b9d62a79a90f3b2185bac 100644 (file)
@@ -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(&param);
        }
        
index a3a3056f168e49ca52608f4162d3305fce859ac8..9f22bcf5c26f0d44cc65ae8155a2470bf6ee8c91 100644 (file)
@@ -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