Jacek Caban : vbscript: Always pass arguments inside parentheses by value.

Alexandre Julliard julliard at winehq.org
Mon Oct 28 16:43:37 CDT 2019


Module: wine
Branch: master
Commit: 2d419b7d7b2ec95e867063bf479f33f9205215c3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2d419b7d7b2ec95e867063bf479f33f9205215c3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 28 18:41:05 2019 +0100

vbscript: Always pass arguments inside parentheses by value.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/vbscript/compile.c      |  3 +++
 dlls/vbscript/interp.c       | 17 +++++++++++++++++
 dlls/vbscript/tests/lang.vbs | 10 +++++-----
 dlls/vbscript/vbscript.h     |  1 +
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 5acf4c005a..2023261399 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -417,6 +417,9 @@ static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *re
         if(FAILED(hres))
             return hres;
 
+        if(args->type == EXPR_BRACKETS && !push_instr(ctx, OP_deref))
+            return E_OUTOFMEMORY;
+
         arg_cnt++;
         args = args->next;
     }
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 11a2a77d82..60c4340d6e 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -1028,6 +1028,23 @@ static HRESULT interp_pop(exec_ctx_t *ctx)
     return S_OK;
 }
 
+static HRESULT interp_deref(exec_ctx_t *ctx)
+{
+    VARIANT copy, *v = stack_top(ctx, 0);
+    HRESULT hres;
+
+    TRACE("%s\n", debugstr_variant(v));
+
+    if(V_VT(v) != (VT_BYREF|VT_VARIANT))
+        return S_OK;
+
+    V_VT(&copy) = VT_EMPTY;
+    hres = VariantCopy(&copy, V_VARIANTREF(v));
+    if(SUCCEEDED(hres))
+        *v = copy;
+    return hres;
+}
+
 static HRESULT interp_new(exec_ctx_t *ctx)
 {
     const WCHAR *arg = ctx->instr->arg1.bstr;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 09c6b4f0ff..8027264bf5 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -1277,11 +1277,11 @@ ok x(0) = 2, "x(0) = " & x(0)
 
 x = Array(1)
 seta0 (x)
-todo_wine_ok x(0) = 1, "x(0) = " & x(0)
+ok x(0) = 1, "x(0) = " & x(0)
 
 x = Array(1)
 call (((seta0))) ((x))
-todo_wine_ok x(0) = 1, "x(0) = " & x(0)
+ok x(0) = 1, "x(0) = " & x(0)
 
 x = Array(1)
 call (((seta0))) (x)
@@ -1293,7 +1293,7 @@ call ok(x(0)(0) = 2, "x(0)(0) = " & x(0)(0))
 
 x = Array(Array(3))
 seta0 (x(0))
-call todo_wine_ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
+call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
 
 y = (seta0)(x)
 ok y = 1, "y = " & y
@@ -1311,7 +1311,7 @@ ok x(0) = 2, "x(0) = " & x(0)
 
 x = Array(1)
 changearg (x(0))
-todo_wine_ok x(0) = 1, "x(0) = " & x(0)
+ok x(0) = 1, "x(0) = " & x(0)
 
 Class ArrClass
     Dim classarr(3)
@@ -1377,7 +1377,7 @@ Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
 
 arr(0) = "not modified"
 modifyarr(arr)
-Call todo_wine_ok(arr(0) = "not modified", "arr(0) = " & arr(0))
+Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
 
 for x = 0 to UBound(arr)
     arr(x) = x
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 0382a80290..33eb1e8305 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -224,6 +224,7 @@ typedef enum {
     X(case,           0, ARG_ADDR,    0)          \
     X(concat,         1, 0,           0)          \
     X(const,          1, ARG_BSTR,    0)          \
+    X(deref,          1, 0,           0)          \
     X(dim,            1, ARG_BSTR,    ARG_UINT)   \
     X(div,            1, 0,           0)          \
     X(double,         1, ARG_DOUBLE,  0)          \




More information about the wine-cvs mailing list