From a8c7e97d0a20ad55640939edb380e1ab4a499d8f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 24 Sep 2009 00:44:30 +0200 Subject: [PATCH] jscript: Fixed to_object for NULL IDispatch. --- dlls/jscript/jsutils.c | 14 ++++++++++++-- dlls/jscript/tests/lang.js | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index c4e3df2c4ec..80cce597481 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -603,8 +603,18 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp) *disp = (IDispatch*)_IDispatchEx_(dispex); break; case VT_DISPATCH: - IDispatch_AddRef(V_DISPATCH(v)); - *disp = V_DISPATCH(v); + if(V_DISPATCH(v)) { + IDispatch_AddRef(V_DISPATCH(v)); + *disp = V_DISPATCH(v); + }else { + DispatchEx *obj; + + hres = create_object(ctx, NULL, &obj); + if(FAILED(hres)) + return hres; + + *disp = (IDispatch*)_IDispatchEx_(obj); + } break; case VT_BOOL: hres = create_bool(ctx, V_BOOL(v), &dispex); diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index eed0589ecb4..353dcd7c73c 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -948,6 +948,11 @@ ok(!nullDisp === true, "!nullDisp = " + !nullDisp); ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp)); ok(nullDisp != new Object(), "nullDisp == new Object()"); ok(new Object() != nullDisp, "new Object() == nullDisp"); +ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'"); +tmp = getVT(Object(nullDisp)); +ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp); +tmp = Object(nullDisp).toString(); +ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp); function do_test() {} function nosemicolon() {} nosemicolon();