Skip to content

Commit 01eab11

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79248: Traversing empty VT_ARRAY throws com_exception
2 parents b4f61d9 + f649ade commit 01eab11

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PHP NEWS
99
. Fixed bug #79242 (COM error constants don't match com_exception codes on
1010
x86). (cmb)
1111
. Fixed bug #79247 (Garbage collecting variant objects segfaults). (cmb)
12+
. Fixed bug #79248 (Traversing empty VT_ARRAY throws com_exception). (cmb)
1213

1314
- CURL:
1415
. Fixed bug #79019 (Copied cURL handles upload empty file). (cmb)

ext/com_dotnet/com_iterator.c

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

189189
/* pre-fetch the element */
190-
if (php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
190+
if (I->sa_max >= bound && php_com_safearray_get_elem(&I->safe_array, &I->v, bound)) {
191191
I->key = bound;
192192
ZVAL_NULL(&ptr);
193193
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)