diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c index 7b031f41922..0272d48cd36 100644 --- a/ext/com_dotnet/com_iterator.c +++ b/ext/com_dotnet/com_iterator.c @@ -185,7 +185,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b SafeArrayGetUBound(V_ARRAY(&I->safe_array), 1, &I->sa_max); /* pre-fetch the element */ - if (php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) { + if (I->sa_max >= bound && php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) { I->key = bound; ZVAL_NULL(&ptr); php_com_zval_from_variant(&ptr, &I->v, I->code_page); diff --git a/ext/com_dotnet/tests/bug79248.phpt b/ext/com_dotnet/tests/bug79248.phpt new file mode 100644 index 00000000000..fda67551a79 --- /dev/null +++ b/ext/com_dotnet/tests/bug79248.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #79248 (Traversing empty VT_ARRAY throws com_exception) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +done