Skip to content

Commit 5869e8a

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-8778: Integer arithmethic with large number variants fails
2 parents bb010ad + 651e0cc commit 5869e8a

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-8655 (Casting an object to array does not unwrap refcount=1
1111
references). (Nicolas Grekas)
1212

13+
- COM:
14+
. Fixed bug GH-8778 (Integer arithmethic with large number variants fails).
15+
(cmb)
16+
1317
- Curl:
1418
. Fixed CURLOPT_TLSAUTH_TYPE is not treated as a string option. (Pierrick)
1519

ext/com_dotnet/com_handlers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,11 @@ static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
453453
switch(type) {
454454
case IS_LONG:
455455
case _IS_NUMBER:
456-
vt = VT_INT;
456+
#if SIZEOF_ZEND_LONG == 4
457+
vt = VT_I4;
458+
#else
459+
vt = VT_I8;
460+
#endif
457461
break;
458462
case IS_DOUBLE:
459463
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)