[PATCH] vbscript: Handle recursive call.

Robert Wilhelm robert.wilhelm at gmx.net
Thu Sep 16 15:25:23 CDT 2021


You must not lookup return value for recursive call.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50758
Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>
---
 dlls/vbscript/interp.c       | 4 +++-
 dlls/vbscript/tests/lang.vbs | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index f648f073bc8..18446ffb4a2 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -135,7 +135,9 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
     HRESULT hres;

     if((ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET)
-       && !wcsicmp(name, ctx->func->name)) {
+       && !wcsicmp(name, ctx->func->name)
+       /* you must not use return value for recursive call */
+       && ((invoke_type != VBDISP_CALLGET) || ((invoke_type == VBDISP_CALLGET) && ( V_VT(&ctx->ret_val) == VT_DISPATCH)))) {
         ref->type = REF_VAR;
         ref->u.v = &ctx->ret_val;
         return S_OK;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index d7865301784..cea34fa40a8 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -1882,6 +1882,12 @@ set arr(0) = new TestPropSyntax
 arr(0).prop = 1
 ok arr(0).prop = 1, "arr(0) = " & arr(0).prop

+function recursingfunction(x)
+    if (x) then exit function
+    call recursingfunction(True)
+end function
+call recursingfunction(False)
+
 function f2(x,y)
 end function

--
2.31.1






More information about the wine-devel mailing list