mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Merge branch 'PHP-8.1'
* PHP-8.1: Don't leak header callback if headers already sent
This commit is contained in:
commit
0652e81041
@ -124,7 +124,11 @@ PHP_FUNCTION(header_register_callback)
|
||||
SG(fci_cache) = empty_fcall_info_cache;
|
||||
}
|
||||
|
||||
ZVAL_COPY(&SG(callback_func), &fci.function_name);
|
||||
/* Don't store callback if headers have already been sent:
|
||||
* It won't get used and we won't have a chance to release it. */
|
||||
if (!SG(headers_sent)) {
|
||||
ZVAL_COPY(&SG(callback_func), &fci.function_name);
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
9
tests/basic/header_register_callback_after_output.phpt
Normal file
9
tests/basic/header_register_callback_after_output.phpt
Normal file
@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Call header_register_callback() after headers sent
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Send headers.\n";
|
||||
header_register_callback(function() { echo "Too late";});
|
||||
?>
|
||||
--EXPECT--
|
||||
Send headers.
|
Loading…
Reference in New Issue
Block a user