Skip to content

Commit 4bdc4da

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79242: COM error constants don't match com_exception codes
2 parents d2befbc + 7f86f99 commit 4bdc4da

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

ext/com_dotnet/com_extension.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,15 @@ PHP_MINIT_FUNCTION(com_dotnet)
245245

246246
#define COM_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS|CONST_PERSISTENT)
247247

248-
#define COM_ERR_CONST(x) { \
248+
#if SIZEOF_ZEND_LONG == 8
249+
# define COM_ERR_CONST(x) { \
249250
zend_long __tmp; \
250251
ULongToIntPtr(x, &__tmp); \
251252
REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \
252253
}
254+
#else
255+
# define COM_ERR_CONST COM_CONST
256+
#endif
253257

254258
COM_CONST(CLSCTX_INPROC_SERVER);
255259
COM_CONST(CLSCTX_INPROC_HANDLER);

ext/com_dotnet/tests/bug79242.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #79242 (COM error constants don't match com_exception codes)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
7+
?>
8+
--FILE--
9+
<?php
10+
var_dump(
11+
DISP_E_DIVBYZERO,
12+
DISP_E_OVERFLOW,
13+
DISP_E_BADINDEX,
14+
MK_E_UNAVAILABLE
15+
);
16+
?>
17+
--EXPECT--
18+
int(-2147352558)
19+
int(-2147352566)
20+
int(-2147352565)
21+
int(-2147221021)
22+

0 commit comments

Comments
 (0)