Module: wine Branch: master Commit: 3bf7255d2335dfe49359a7b17c551149a55c513f URL: http://source.winehq.org/git/wine.git/?a=commit;h=3bf7255d2335dfe49359a7b17c...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Mar 27 11:01:43 2013 +0100
jscript: Added to_flat_string helper and use it to access string buffer in activex.c.
---
dlls/jscript/activex.c | 9 +++++---- dlls/jscript/jscript.h | 1 + dlls/jscript/jsutils.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/activex.c b/dlls/jscript/activex.c index 58c2574..c7d9a66 100644 --- a/dlls/jscript/activex.c +++ b/dlls/jscript/activex.c @@ -143,7 +143,8 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid) static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - jsstr_t * progid; + jsstr_t * progid_str; + const WCHAR *progid; IDispatch *disp; IUnknown *obj; HRESULT hres; @@ -166,12 +167,12 @@ static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag return E_NOTIMPL; }
- hres = to_string(ctx, argv[0], &progid); + hres = to_flat_string(ctx, argv[0], &progid_str, &progid); if(FAILED(hres)) return hres;
- obj = create_activex_object(ctx, progid->str); - jsstr_release(progid); + obj = create_activex_object(ctx, progid); + jsstr_release(progid_str); if(!obj) return throw_generic_error(ctx, JS_E_CANNOT_CREATE_OBJ, NULL);
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 135b77f..aed2585 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -322,6 +322,7 @@ HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN; HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN; HRESULT to_uint32(script_ctx_t*,jsval_t,UINT32*) DECLSPEC_HIDDEN; HRESULT to_string(script_ctx_t*,jsval_t,jsstr_t**) DECLSPEC_HIDDEN; +HRESULT to_flat_string(script_ctx_t*,jsval_t,jsstr_t**,const WCHAR**) DECLSPEC_HIDDEN; HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index d141378..60ca474 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -776,6 +776,23 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str) return *str ? S_OK : E_OUTOFMEMORY; }
+HRESULT to_flat_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str, const WCHAR **ret_str) +{ + HRESULT hres; + + hres = to_string(ctx, val, str); + if(FAILED(hres)) + return hres; + + *ret_str = jsstr_flatten(*str); + if(!*ret_str) { + jsstr_release(*str); + return E_OUTOFMEMORY; + } + + return S_OK; +} + /* ECMA-262 3rd Edition 9.9 */ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp) {