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
4 changes: 1 addition & 3 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,7 @@ static inline zend_result ct_eval_func_call(
zval_ptr_dtor(result);
zend_clear_exception();
retval = FAILURE;
}

if (EG(capture_warnings_during_sccp) > 1) {
} else if (EG(capture_warnings_during_sccp) > 1) {
zval_ptr_dtor(result);
retval = FAILURE;
}
Expand Down
27 changes: 27 additions & 0 deletions ext/opcache/tests/opt/gh19792.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
GH-19792 (SCCP causes UAF for return value if both warning and exception are triggered)
--EXTENSIONS--
opcache
zend_test
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php

function foo()
{
return \zend_test_gh19792();
}

try {
foo();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
Warning: a warning in %s on line %d
an exception
9 changes: 9 additions & 0 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,3 +1528,12 @@ static PHP_FUNCTION(zend_test_gh18756)
zend_mm_gc(heap);
zend_mm_shutdown(heap, true, false);
}

static PHP_FUNCTION(zend_test_gh19792)
{
ZEND_PARSE_PARAMETERS_NONE();

RETVAL_STRING("this is a non-interned string");
zend_error(E_WARNING, "a warning");
zend_throw_error(NULL, "an exception");
}
3 changes: 3 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ function zend_test_is_zend_ptr(int $addr): bool {}
function zend_test_log_err_debug(string $str): void {}

function zend_test_gh18756(): void {}

/** @compile-time-eval */
function zend_test_gh19792(): void {}
}

namespace ZendTestNS {
Expand Down
6 changes: 5 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading