com php-src: fix #66375 bad logic in sapi header callback routine: main/SAPI.c
| From: | Joe Watkins | Date: | Wed, 01 Jan 2014 12:58:18 +0000 |
| Subject: | com php-src: fix #66375 bad logic in sapi header callback routine: main/SAPI.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75519@lists.php.net to get a copy of this message | ||
Commit: 3c3ff434329d2f505b00a79bacfdef95ca96f0d2
Author: krakjoe <joe.watkins@live.co.uk> Wed, 1 Jan 2014 12:58:18 +0000
Parents: 3b6afb1bd63ef92f9914867f04bedeea90e21789
Branches: PHP-5.4 PHP-5.5 PHP-5..6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3c3ff434329d2f505b00a79bacfdef95ca96f0d2
Log:
fix #66375 bad logic in sapi header callback routine
Bugs:
https://bugs.php.net/66375
Changed paths:
M main/SAPI.c
Diff:
diff --git a/main/SAPI.c b/main/SAPI.c
index dcb2da6..9ffc258 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -137,6 +137,7 @@ PHP_FUNCTION(header_register_callback)
efree(callback_name);
RETURN_FALSE;
}
+
efree(callback_name);
if (SG(callback_func)) {
@@ -144,10 +145,10 @@ PHP_FUNCTION(header_register_callback)
SG(fci_cache) = empty_fcall_info_cache;
}
- Z_ADDREF_P(callback_func);
-
SG(callback_func) = callback_func;
-
+
+ Z_ADDREF_P(SG(callback_func));
+
RETURN_TRUE;
}
/* }}} */
@@ -156,24 +157,30 @@ static void sapi_run_header_callback(TSRMLS_D)
{
int error;
zend_fcall_info fci;
+ char *callback_name = NULL;
+ char *callback_error = NULL;
zval *retval_ptr = NULL;
-
- fci.size = sizeof(fci);
- fci.function_table = EG(function_table);
- fci.object_ptr = NULL;
- fci.function_name = SG(callback_func);
- fci.retval_ptr_ptr = &retval_ptr;
- fci.param_count = 0;
- fci.params = NULL;
- fci.no_separation = 0;
- fci.symbol_table = NULL;
-
- error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC);
- if (error == FAILURE) {
+
+ if (zend_fcall_info_init(SG(callback_func), 0, &fci, &SG(fci_cache), &callback_name,
&callback_error TSRMLS_CC) == SUCCESS) {
+ fci.retval_ptr_ptr = &retval_ptr;
+
+ error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC);
+ if (error == FAILURE) {
+ goto callback_failed;
+ } else if (retval_ptr) {
+ zval_ptr_dtor(&retval_ptr);
+ }
+ } else {
+callback_failed:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the sapi_header_callback");
- } else if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
}
+
+ if (callback_name) {
+ efree(callback_name);
+ }
+ if (callback_error) {
+ efree(callback_error);
+ }
}
SAPI_API void sapi_handle_post(void *arg TSRMLS_DC)