Skip to content

Commit 9e1b285

Browse files
committed
Fix GH-22142: Assertion failure in zendi_try_get_long() on IS_UNDEF.
close GH-22143
1 parent 6cdf46f commit 9e1b285

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ PHP NEWS
1919
. Enabled the TAILCALL VM on Windows when compiling with Clang >= 19 x86_64.
2020
(henderkes)
2121
. Deprecate specifying a nullable return type for __debugInfo(). (timwolla)
22+
. Fixed bug GH-22142 (Assertion failure in zendi_try_get_long() on IS_UNDEF).
23+
(David Carlier)
2224

2325
- BCMath:
2426
. Added NUL-byte validation to BCMath functions. (jorgsowa)

Zend/zend_operators.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *
448448
ZEND_ASSERT(Z_TYPE(dst) == IS_LONG);
449449
return Z_LVAL(dst);
450450
}
451+
case IS_UNDEF:
451452
case IS_RESOURCE:
452453
case IS_ARRAY:
453454
*failed = true;

ext/zlib/tests/gh22142.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-22142 (Assertion failure in zendi_try_get_long() on IS_UNDEF)
3+
--EXTENSIONS--
4+
zlib
5+
--FILE--
6+
<?php
7+
8+
class Options {
9+
public int $level;
10+
}
11+
12+
try {
13+
deflate_init(ZLIB_ENCODING_DEFLATE, new Options());
14+
} catch (TypeError $e) {
15+
echo $e->getMessage(), PHP_EOL;
16+
}
17+
18+
?>
19+
--EXPECT--
20+
deflate_init(): Argument #2 ($options) the value for option "level" must be of type int, null given

0 commit comments

Comments
 (0)