Skip to content

Commit 790be97

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-8778: Integer arithmethic with large number variants fails
2 parents b08076e + 5869e8a commit 790be97

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed bug GH-7821 and GH-8418 (Allow arbitrary const expressions in backed
1111
enums). (ilutov)
1212

13+
- COM:
14+
. Fixed bug GH-8778 (Integer arithmethic with large number variants fails).
15+
(cmb)
16+
1317
- Curl:
1418
. Added new constants from cURL 7.62 to 7.80. (Pierrick)
1519
. New function curl_upkeep(). (Pierrick)

ext/com_dotnet/com_handlers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
452452
switch(type) {
453453
case IS_LONG:
454454
case _IS_NUMBER:
455-
vt = VT_INT;
455+
#if SIZEOF_ZEND_LONG == 4
456+
vt = VT_I4;
457+
#else
458+
vt = VT_I8;
459+
#endif
456460
break;
457461
case IS_DOUBLE:
458462
vt = VT_R8;

ext/com_dotnet/tests/gh8778.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug GH-8778 (Integer arithmethic with large number variants fails)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("com_dotnet")) die("skip com_dotnet extension not available");
6+
if (PHP_INT_SIZE < 8) die("skip for 64bit only");
7+
?>
8+
--FILE--
9+
<?php
10+
$int = 0x100000000;
11+
var_dump(
12+
$int,
13+
new variant($int) + 1
14+
);
15+
?>
16+
--EXPECT--
17+
int(4294967296)
18+
int(4294967297)

0 commit comments

Comments
 (0)