Module: wine Branch: master Commit: fa09e3f36cb84e67cbd38f86398c7ff72732727c URL: https://source.winehq.org/git/wine.git/?a=commit;h=fa09e3f36cb84e67cbd38f863...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Mon Apr 11 18:58:52 2022 +0300
jscript: Throw proper error when invoking non-method builtin.
Instead of crashing.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/dispex.c | 3 +++ dlls/jscript/tests/api.js | 2 ++ dlls/mshtml/tests/documentmode.js | 13 +++++++++++++ 3 files changed, 18 insertions(+)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 6ee02a0d0f5..319617b7a52 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -560,6 +560,9 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t case PROP_BUILTIN: { jsval_t vthis;
+ if(!prop->u.p->invoke) + return JS_E_FUNCTION_EXPECTED; + if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) { WARN("%s is not a constructor\n", debugstr_w(prop->name)); return E_INVALIDARG; diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 9eaeddd5c73..fe336d46ba9 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -2611,6 +2611,8 @@ testException(function() {delete false;}, "E_INVALID_DELETE"); testException(function() {undefined.toString();}, "E_OBJECT_EXPECTED"); testException(function() {null.toString();}, "E_OBJECT_EXPECTED"); testException(function() {RegExp.prototype.toString.call(new Object());}, "E_REGEXP_EXPECTED"); +testException(function() {/a/.lastIndex();}, "E_NOT_FUNC"); +testException(function() {"a".length();}, "E_NOT_FUNC");
testException(function() { return arguments.callee(); }, "E_STACK_OVERFLOW");
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 3f772cf092f..55de9b7158f 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1307,6 +1307,19 @@ sync_test("builtins_diffs", function() { }catch(e) { ok(e.number === 0xa1398 - 0x80000000, "RegExp.toString with non-regexp: exception = " + e.number); } + + try { + /a/.lastIndex(); + ok(false, "/a/.lastIndex(): expected exception"); + }catch(e) { + ok(e.number === 0xa138a - 0x80000000, "/a/.lastIndex(): exception = " + e.number); + } + try { + "a".length(); + ok(false, ""a".length(): expected exception"); + }catch(e) { + ok(e.number === 0xa138a - 0x80000000, ""a".length(): exception = " + e.number); + } });
sync_test("__proto__", function() {