Skip to content

Commit 9e6358a

Browse files
committed
Fix #79299: com_print_typeinfo prints duplicate variables
`lastid` has to retain its value during the traversal, so we move it to an outer scope. Patch contributed by Litiano Moura.
1 parent f133f00 commit 9e6358a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PHP NEWS
88
. Fixed bug #79242 (COM error constants don't match com_exception codes on
99
x86). (cmb)
1010
. Fixed bug #79248 (Traversing empty VT_ARRAY throws com_exception). (cmb)
11+
. Fixed bug #79299 (com_print_typeinfo prints duplicate variables). (Litiano
12+
Moura)
1113

1214
- DOM:
1315
. Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,

ext/com_dotnet/com_typeinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
436436
char *ansiname = NULL;
437437
size_t ansinamelen;
438438
int ret = 0;
439+
DISPID lastid = 0; /* for props */
439440

440441
if (FAILED(ITypeInfo_GetTypeAttr(typeinfo, &attr))) {
441442
return 0;
@@ -469,7 +470,6 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
469470
/* So we've got the dispatch interface; lets list the event methods */
470471
for (i = 0; i < attr->cFuncs; i++) {
471472
zval tmp;
472-
DISPID lastid = 0; /* for props */
473473
int isprop;
474474

475475
if (FAILED(ITypeInfo_GetFuncDesc(typeinfo, i, &func)))

ext/com_dotnet/tests/bug79299.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #79299 (com_print_typeinfo prints duplicate variables)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$dict = new COM("Scripting.Dictionary");
10+
ob_start();
11+
com_print_typeinfo($dict);
12+
$typeinfo = ob_get_clean();
13+
preg_match_all('/\/\* DISPID=9 \*\//', $typeinfo, $matches);
14+
var_dump($matches[0]);
15+
?>
16+
--EXPECT--
17+
array(1) {
18+
[0]=>
19+
string(14) "/* DISPID=9 */"
20+
}

0 commit comments

Comments
 (0)