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. --- ext/com_dotnet/com_typeinfo.c | 2 +- ext/com_dotnet/tests/bug79299.phpt | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ext/com_dotnet/tests/bug79299.phpt (limited to 'ext/com_dotnet') 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