diff options
-rw-r--r-- | ext/com_dotnet/com_handlers.c | 5 | ||||
-rw-r--r-- | ext/com_dotnet/tests/bug78694.phpt | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 1036abb977..1a5d9c3046 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -122,6 +122,11 @@ static void com_write_dimension(zend_object *object, zval *offset, zval *value) obj = (php_com_dotnet_object*) object; + if (offset == NULL) { + php_com_throw_exception(DISP_E_BADINDEX, "appending to variants is not supported"); + return; + } + if (V_VT(&obj->v) == VT_DISPATCH) { ZVAL_COPY_VALUE(&args[0], offset); ZVAL_COPY_VALUE(&args[1], value); diff --git a/ext/com_dotnet/tests/bug78694.phpt b/ext/com_dotnet/tests/bug78694.phpt new file mode 100644 index 0000000000..adf0c828ca --- /dev/null +++ b/ext/com_dotnet/tests/bug78694.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #78694 (Appending to a variant array causes segfault) +--SKIPIF-- +<?php +if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available'); +?> +--FILE-- +<?php +foreach ([new com('WScript.Shell'), new variant([])] as $var) { + try { + $var[] = 42; + } catch (com_exception $ex) { + var_dump($ex->getMessage()); + } +} +?> +--EXPECT-- +string(38) "appending to variants is not supported" +string(38) "appending to variants is not supported" |