summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-02-23 23:23:12 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-02-23 23:31:36 +0100
commit9e6358af36e71fa867b3de24dae2ec76d678c428 (patch)
tree98154ab4e09b8e1c267def8c54dee563b7cdb146 /ext
parentf133f0024ec801dc9636ee5bf84a93de1300d4b2 (diff)
downloadphp-git-9e6358af36e71fa867b3de24dae2ec76d678c428.tar.gz
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.
Diffstat (limited to 'ext')
-rw-r--r--ext/com_dotnet/com_typeinfo.c2
-rw-r--r--ext/com_dotnet/tests/bug79299.phpt20
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index 330d7b0052..f3cecd82f5 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -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;
@@ -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)))
diff --git a/ext/com_dotnet/tests/bug79299.phpt b/ext/com_dotnet/tests/bug79299.phpt
new file mode 100644
index 0000000000..99c1a99742
--- /dev/null
+++ b/ext/com_dotnet/tests/bug79299.phpt
@@ -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 */"
+} \ No newline at end of file