We need to initialize the result variable in the exceptional
case as well.
Fixes oss-fuzz #25526.
--- /dev/null
+--TEST--
+Handling of undef variable exception in JMP_NULL
+--FILE--
+<?php
+
+set_error_handler(function($_, $m) {
+ throw new Exception($m);
+});
+
+try {
+ $foo?->foo;
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Undefined variable $foo
zval *result = EX_VAR(opline->result.var);
if (EXPECTED(opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_EXPR)) {
+ ZVAL_NULL(result);
if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
SAVE_OPLINE();
ZVAL_UNDEFINED_OP1();
HANDLE_EXCEPTION();
}
}
-
- ZVAL_NULL(result);
} else if (opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_ISSET) {
ZVAL_FALSE(result);
} else {
zval *result = EX_VAR(opline->result.var);
if (EXPECTED(opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_EXPR)) {
+ ZVAL_NULL(result);
if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
SAVE_OPLINE();
ZVAL_UNDEFINED_OP1();
HANDLE_EXCEPTION();
}
}
-
- ZVAL_NULL(result);
} else if (opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_ISSET) {
ZVAL_FALSE(result);
} else {
zval *result = EX_VAR(opline->result.var);
if (EXPECTED(opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_EXPR)) {
+ ZVAL_NULL(result);
if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
SAVE_OPLINE();
ZVAL_UNDEFINED_OP1();
HANDLE_EXCEPTION();
}
}
-
- ZVAL_NULL(result);
} else if (opline->extended_value == ZEND_SHORT_CIRCUITING_CHAIN_ISSET) {
ZVAL_FALSE(result);
} else {