Skip to content

Commit

Permalink
Fix #79299: com_print_typeinfo prints duplicate variables
Browse files Browse the repository at this point in the history
`lastid` has to retain its value during the traversal, so we move it to
an outer scope.

Patch contributed by Litiano Moura.
  • Loading branch information
cmb69 committed Feb 23, 2020
1 parent f133f00 commit 9e6358a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PHP NEWS
. Fixed bug #79242 (COM error constants don't match com_exception codes on
x86). (cmb)
. Fixed bug #79248 (Traversing empty VT_ARRAY throws com_exception). (cmb)
. Fixed bug #79299 (com_print_typeinfo prints duplicate variables). (Litiano
Moura)

- DOM:
. Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
Expand Down
2 changes: 1 addition & 1 deletion ext/com_dotnet/com_typeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
char *ansiname = NULL;
size_t ansinamelen;
int ret = 0;
DISPID lastid = 0; /* for props */

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

if (FAILED(ITypeInfo_GetFuncDesc(typeinfo, i, &func)))
Expand Down
20 changes: 20 additions & 0 deletions ext/com_dotnet/tests/bug79299.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #79299 (com_print_typeinfo prints duplicate variables)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$dict = new COM("Scripting.Dictionary");
ob_start();
com_print_typeinfo($dict);
$typeinfo = ob_get_clean();
preg_match_all('/\/\* DISPID=9 \*\//', $typeinfo, $matches);
var_dump($matches[0]);
?>
--EXPECT--
array(1) {
[0]=>
string(14) "/* DISPID=9 */"
}

0 comments on commit 9e6358a

Please sign in to comment.