Jacek Caban : jscript: Fixed to_object for NULL IDispatch.
Alexandre Julliard
julliard at winehq.org
Thu Sep 24 10:54:53 CDT 2009
Module: wine
Branch: master
Commit: a8c7e97d0a20ad55640939edb380e1ab4a499d8f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a8c7e97d0a20ad55640939edb380e1ab4a499d8f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Sep 24 00:44:30 2009 +0200
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 c4e3df2..80cce59 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 eed0589..353dcd7 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();
More information about the wine-cvs
mailing list