Skip to content

Commit 42e7de1

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79248: Traversing empty VT_ARRAY throws com_exception
2 parents 377ac2a + 01eab11 commit 42e7de1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ext/com_dotnet/com_iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b
185185
SafeArrayGetUBound(V_ARRAY(&I->safe_array), 1, &I->sa_max);
186186

187187
/* pre-fetch the element */
188-
if (php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
188+
if (I->sa_max >= bound && php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
189189
I->key = bound;
190190
ZVAL_NULL(&ptr);
191191
php_com_zval_from_variant(&ptr, &I->v, I->code_page);

ext/com_dotnet/tests/bug79248.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #79248 (Traversing empty VT_ARRAY throws com_exception)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$v = new variant([], VT_ARRAY);
10+
foreach ($v as $el) {
11+
var_dump($el);
12+
}
13+
echo "done\n";
14+
?>
15+
--EXPECT--
16+
done

0 commit comments

Comments
 (0)