Skip to content
Closed
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
23 changes: 23 additions & 0 deletions Zend/tests/gh13931.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
GH-13931 (Applying zero offset to null pointer in Zend/zend_opcode.c)
--FILE--
<?php

register_shutdown_function(function() {
var_dump(eval("return 1+3;"));
});

eval(<<<EVAL
function foo () {
try {
break;
} finally {
}
}
foo();
EVAL);

?>
--EXPECTF--
Fatal error: 'break' not in the 'loop' or 'switch' context in %s on line %d
int(4)
8 changes: 8 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,14 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
/* restore memory limit */
zend_set_memory_limit(PG(memory_limit));
zend_objects_store_mark_destructed(&EG(objects_store));
if (CG(in_compilation) && (type == E_COMPILE_ERROR || type == E_PARSE)) {
/* We bailout during compilation which may for example leave stale entries in CG(loop_var_stack).
* If code is compiled during shutdown, we need to make sure the compiler is reset to a clean state,
* otherwise this will lead to incorrect compilation during shutdown.
* We don't do a full re-initialization via init_compiler() because that will also reset streams and resources. */
shutdown_compiler();
zend_init_compiler_data_structures();
}
zend_bailout();
return;
}
Expand Down
21 changes: 21 additions & 0 deletions sapi/phpdbg/tests/gh13931.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Applying zero offset to null pointer in Zend/zend_opcode.c
--FILE--
<?php
function foo () {
try {
break;
} finally {
}
}
foo();
?>
--PHPDBG--
ev 1 + 3
ev 2 ** 3
q
--EXPECTF--
Fatal error: 'break' not in the 'loop' or 'switch' context in %s on line %d
prompt> 4
prompt> 8
prompt>