Instead of crashing.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- 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 6ee02a0..319617b 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 9eaeddd..fe336d4 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 3f772cf..55de9b7 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() {