Skip to content

Commit b00cc33

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78694: Appending to a variant array causes segfault
2 parents 49327e2 + ee6a71c commit b00cc33

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/com_dotnet/com_handlers.c

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ static void com_write_dimension(zend_object *object, zval *offset, zval *value)
122122

123123
obj = (php_com_dotnet_object*) object;
124124

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

ext/com_dotnet/tests/bug78694.phpt

+19
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)