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 @@ -34,6 +34,8 @@ PHP NEWS

- Standard:
. Fixed bug GH-17403 (Potential deadlock when putenv fails). (nielsdos)
. Fixed bug GH-18509 (Dynamic calls to assert() ignore zend.assertions).
(timwolla)

- Windows:
. Fix leak+crash with sapi_windows_set_ctrl_handler(). (nielsdos)
Expand Down
6 changes: 5 additions & 1 deletion ext/standard/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ PHP_FUNCTION(assert)
zend_string *description_str = NULL;
zend_object *description_obj = NULL;

if (!ASSERTG(active)) {
/* EG(assertions) <= 0 is only reachable by dynamic calls to assert(),
* since calls known at compile time will skip the entire call when
* assertions are disabled.
*/
if (!ASSERTG(active) || EG(assertions) <= 0) {
RETURN_TRUE;
}

Expand Down
23 changes: 23 additions & 0 deletions ext/standard/tests/assert/gh18509.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
GH-18509: Dynamic calls to assert() ignore zend.assertions
--INI--
zend.assertions=0
--FILE--
<?php

$c = "assert";

$c(false);

var_dump(array_map(assert(...), [true, true, false]));

?>
--EXPECT--
array(3) {
[0]=>
bool(true)
[1]=>
bool(true)
[2]=>
bool(true)
}
Loading