Gabriel Ivăncescu : jscript: Return JS_E_INVALID_PROPERTY in jsdisp_call_name if property is not found.

Alexandre Julliard julliard at winehq.org
Mon Mar 21 17:20:25 CDT 2022


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

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Mon Mar 21 17:58:28 2022 +0200

jscript: Return JS_E_INVALID_PROPERTY in jsdisp_call_name if property is not found.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/dispex.c    |  3 +++
 dlls/jscript/tests/run.c | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index e14001074ff..1cacd49a1fa 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -2007,6 +2007,9 @@ HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned
     if(FAILED(hres))
         return hres;
 
+    if(!prop || prop->type == PROP_DELETED)
+        return JS_E_INVALID_PROPERTY;
+
     return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, NULL);
 }
 
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 63d81150e0e..86d6fa46212 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -2946,6 +2946,28 @@ static void test_script_exprs(void)
     CHECK_CALLED(global_success_d);
     CHECK_CALLED(global_success_i);
 
+    hres = parse_script_expr(L"var o=new Object(); Object.prototype.toLocaleString.call(o)", &v, NULL);
+    ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    ok(!lstrcmpW(V_BSTR(&v), L"[object Object]"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+
+    hres = parse_script_expr(L"var o=new Object(); Object.prototype.toString = function() {return \"wine\";}; Object.prototype.toLocaleString.call(o)", &v, NULL);
+    ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    todo_wine
+    ok(!lstrcmpW(V_BSTR(&v), L"wine"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+
+    hres = parse_script_expr(L"var o=new Object(); delete Object.prototype.toString; Object.prototype.toLocaleString.call(o)", &v, NULL);
+    ok(hres == 0x800a01b6, "parse_script_expr failed: %08lx\n", hres);
+
+    hres = parse_script_expr(L"var o=new Object(); o.toString = function() {return \"wine\";}; Object.prototype.toLocaleString.call(o)", &v, NULL);
+    ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    ok(!lstrcmpW(V_BSTR(&v), L"wine"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+
     test_default_value();
     test_retval();
 




More information about the wine-cvs mailing list