From 9e6358af36e71fa867b3de24dae2ec76d678c428 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 23 Feb 2020 23:23:12 +0100 Subject: 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. --- NEWS | 2 ++ ext/com_dotnet/com_typeinfo.c | 2 +- ext/com_dotnet/tests/bug79299.phpt | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ext/com_dotnet/tests/bug79299.phpt diff --git a/NEWS b/NEWS index c5eaa64e77..0208b395e8 100644 --- a/NEWS +++ b/NEWS @@ -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, 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-- + +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + string(14) "/* DISPID=9 */" +} \ No newline at end of file -- cgit v1.2.1