Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ PHP NEWS
while COW violation flag is still set). (alexandre-daubois)
. Invalid mode values now throw in array_filter() instead of being silently
defaulted to 0. (Jorg Sowa)
. Fixed bug GH-21058 (error_log() crashes with message_type 3 and
null destination). (David Carlier)

- Streams:
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
Expand Down
17 changes: 17 additions & 0 deletions Zend/tests/ast/gh21072.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
(unset) cast must not be allowed in constant expressions
--CREDITS--
Viet Hoang Luu (@vi3tL0u1s)
--FILE--
<?php
try {
class C {
public $p = (unset) C::class;
}
new C;
} catch (Error $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
Fatal error: The (unset) cast is no longer supported in %s on line %d
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -12564,6 +12564,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
zend_eval_const_expr(&ast->child[1]);
return;
case ZEND_AST_CAST:
if (ast->attr == IS_NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "The (unset) cast is no longer supported");
}
zend_eval_const_expr(&ast->child[0]);
if (ast->child[0]->kind == ZEND_AST_ZVAL
&& zend_try_ct_eval_cast(&result, ast->attr, zend_ast_get_zval(ast->child[0]))) {
Expand Down
4 changes: 1 addition & 3 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,7 @@ static int date_object_compare_timezone(zval *tz1, zval *tz2);

/* {{{ Module struct */
zend_module_entry date_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
NULL,
STANDARD_MODULE_HEADER,
"date", /* extension name */
ext_functions, /* function list */
PHP_MINIT(date), /* process startup */
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ PHPAPI zend_result _php_error_log(int opt_err, const zend_string *message, const
return FAILURE;

case 3: /*save to a file */
stream = php_stream_open_wrapper(ZSTR_VAL(opt), "a", REPORT_ERRORS, NULL);
stream = php_stream_open_wrapper(opt ? ZSTR_VAL(opt) : NULL, "a", REPORT_ERRORS, NULL);
if (!stream) {
return FAILURE;
}
Expand Down
13 changes: 13 additions & 0 deletions ext/standard/tests/general_functions/gh21058.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
GH-21058 (error_log() crash with null destination and message type 3)
--FILE--
<?php

try {
error_log("test", 3, null);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Path must not be empty