Commit 9e1b285f65a for php.net
commit 9e1b285f65a5df3fa5366e6c8241152a4ceb88d4
Author: David Carlier <devnexen@gmail.com>
Date: Mon May 25 06:02:18 2026 +0100
Fix GH-22142: Assertion failure in zendi_try_get_long() on IS_UNDEF.
close GH-22143
diff --git a/NEWS b/NEWS
index aa5e42b3667..23212414d36 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ PHP NEWS
. Enabled the TAILCALL VM on Windows when compiling with Clang >= 19 x86_64.
(henderkes)
. Deprecate specifying a nullable return type for __debugInfo(). (timwolla)
+ . Fixed bug GH-22142 (Assertion failure in zendi_try_get_long() on IS_UNDEF).
+ (David Carlier)
- BCMath:
. Added NUL-byte validation to BCMath functions. (jorgsowa)
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index c54f4f0c2a2..a43fdcc9a48 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -448,6 +448,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *
ZEND_ASSERT(Z_TYPE(dst) == IS_LONG);
return Z_LVAL(dst);
}
+ case IS_UNDEF:
case IS_RESOURCE:
case IS_ARRAY:
*failed = true;
diff --git a/ext/zlib/tests/gh22142.phpt b/ext/zlib/tests/gh22142.phpt
new file mode 100644
index 00000000000..84397a4e85a
--- /dev/null
+++ b/ext/zlib/tests/gh22142.phpt
@@ -0,0 +1,20 @@
+--TEST--
+GH-22142 (Assertion failure in zendi_try_get_long() on IS_UNDEF)
+--EXTENSIONS--
+zlib
+--FILE--
+<?php
+
+class Options {
+ public int $level;
+}
+
+try {
+ deflate_init(ZLIB_ENCODING_DEFLATE, new Options());
+} catch (TypeError $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+deflate_init(): Argument #2 ($options) the value for option "level" must be of type int, null given