Skip to content

Commit ce035dc

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #78694: Appending to a variant array causes segfault
2 parents c7c7ab5 + 45a7723 commit ce035dc

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ PHP NEWS
77
. Fixed bug #78656 (Parse errors classified as highest log-level). (Erik
88
Lundin)
99

10+
- COM:
11+
. Fixed bug #78694 (Appending to a variant array causes segfault). (cmb)
12+
1013
- Date:
1114
. Fixed bug #70153 (\DateInterval incorrectly unserialized). (Maksim Iakunin)
1215

ext/com_dotnet/com_handlers.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ static void com_write_dimension(zval *object, zval *offset, zval *value)
123123

124124
obj = CDNO_FETCH(object);
125125

126+
if (offset == NULL) {
127+
php_com_throw_exception(DISP_E_BADINDEX, "appending to variants is not supported");
128+
return;
129+
}
130+
126131
if (V_VT(&obj->v) == VT_DISPATCH) {
127132
ZVAL_COPY_VALUE(&args[0], offset);
128133
ZVAL_COPY_VALUE(&args[1], value);

ext/com_dotnet/tests/bug78694.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #78694 (Appending to a variant array causes segfault)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
foreach ([new com('WScript.Shell'), new variant([])] as $var) {
10+
try {
11+
$var[] = 42;
12+
} catch (com_exception $ex) {
13+
var_dump($ex->getMessage());
14+
}
15+
}
16+
?>
17+
--EXPECT--
18+
string(38) "appending to variants is not supported"
19+
string(38) "appending to variants is not supported"

0 commit comments

Comments
 (0)