From 2d65d714a3bfbf7ebca8e958c417b356f99c6753 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 22 Nov 2023 13:19:10 +0300 Subject: [PATCH] Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error --- ext/opcache/jit/zend_jit_helpers.c | 3 ++- ext/opcache/tests/jit/gh12748.phpt | 35 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/jit/gh12748.phpt diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 5a68e15588e..95ff48dd4f9 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1135,7 +1135,8 @@ try_string_offset: goto try_string_offset; default: zend_jit_illegal_string_offset(dim); - break; + ZVAL_NULL(result); + return; } offset = zval_get_long_func(dim, /* is_strict */ false); diff --git a/ext/opcache/tests/jit/gh12748.phpt b/ext/opcache/tests/jit/gh12748.phpt new file mode 100644 index 00000000000..d7580fdb9ab --- /dev/null +++ b/ext/opcache/tests/jit/gh12748.phpt @@ -0,0 +1,35 @@ +--TEST-- +GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +--FILE-- +getMessage(), "\n"; +} +try { + echo "empty():\n"; + var_dump(empty($container[new stdClass()])); +} catch (\Throwable $e) { + echo $e->getMessage(), "\n"; +} +try { + echo "Coalesce():\n"; + var_dump($container[new stdClass()] ?? 'default'); +} catch (\Throwable $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +isset(): +bool(false) +empty(): +bool(true) +Coalesce(): +Cannot access offset of type stdClass on string